title: PHP Parsing XML
body: <p>i am having some problem with parsing XML. </p>
  
  <p><strong>What i am doing:</strong>
  I am spliting 1 XML to many and also editing few things for new one. And it works!!</p>
  
  <p><strong>Where is problem:</strong>
  After Parsing not all parts are same, to be more specifc in some of them are just 2 Labor Rate Details, in another there can be 5.:</p>
  
  <p>So some looks like:</p>
  
  <pre><code>  &lt;LaborRateList&gt;
      &lt;LaborRateDetail&gt;
       &lt;Role&gt;Labor&lt;/Role&gt;
       &lt;Category&gt;1&lt;/Category&gt;
       &lt;Rate Cur="CZK" Unit="h" MinValue="0" MaxValue="0"&gt;250.0&lt;/Rate&gt;
      &lt;/LaborRateDetail&gt;
      &lt;LaborRateDetail&gt;
       &lt;Role&gt;Paint&lt;/Role&gt;
       &lt;Category&gt;2&lt;/Category&gt;
       &lt;Rate Cur="CZK" Unit="h" MinValue="0" MaxValue="0"&gt;350.0&lt;/Rate&gt;
      &lt;/LaborRateDetail&gt;
     &lt;/LaborRateList&gt;
  </code></pre>
  
  <p>And another:</p>
  
  <pre><code>   &lt;LaborRateList&gt;
      &lt;LaborRateDetail&gt;
       &lt;Role&gt;Labor&lt;/Role&gt;
       &lt;Category&gt;1&lt;/Category&gt;
       &lt;Rate Cur="CZK" Unit="h" MinValue="0" MaxValue="0"&gt;250.0&lt;/Rate&gt;
      &lt;/LaborRateDetail&gt;
      &lt;LaborRateDetail&gt;
       &lt;Role&gt;Labor&lt;/Role&gt;
       &lt;Category&gt;1&lt;/Category&gt;
       &lt;Rate Cur="CZK" Unit="h" MinValue="0" MaxValue="0"&gt;250.0&lt;/Rate&gt;
      &lt;/LaborRateDetail&gt;
      &lt;LaborRateDetail&gt;
       &lt;Role&gt;Labor&lt;/Role&gt;
       &lt;Category&gt;1&lt;/Category&gt;
       &lt;Rate Cur="CZK" Unit="h" MinValue="0" MaxValue="0"&gt;250.0&lt;/Rate&gt;
      &lt;/LaborRateDetail&gt;
      &lt;LaborRateDetail&gt;
       &lt;Role&gt;Labor&lt;/Role&gt;
       &lt;Category&gt;1&lt;/Category&gt;
       &lt;Rate Cur="CZK" Unit="h" MinValue="0" MaxValue="0"&gt;250.0&lt;/Rate&gt;
      &lt;/LaborRateDetail&gt;
      &lt;LaborRateDetail&gt;
       &lt;Role&gt;Paint&lt;/Role&gt;
       &lt;Category&gt;2&lt;/Category&gt;
       &lt;Rate Cur="CZK" Unit="h" MinValue="0" MaxValue="0"&gt;350.0&lt;/Rate&gt;
      &lt;/LaborRateDetail&gt;
     &lt;/LaborRateList&gt;
  </code></pre>
  
  <p>i was trying to find out how to not insert anything if there is no more labor rates.
  What i try was check if there is anything in variabile and if not write nothing so my code looks like:</p>
  
  <pre><code>//RATE3 PART     
  var_dump($value-&gt;Contract-&gt;LaborRateList-&gt;LaborRateDetail[2]-&gt;Role);
      if ($value-&gt;Contract-&gt;LaborRateList-&gt;LaborRateDetail[2]-&gt;Role == 0)
  //SOME CODE HERE
  </code></pre>
  
  <p>But i am getting error:</p>
  
  <pre><code>Notice: Trying to get property of non-object in C:\xampp\htdocs\xampp\provisioning\index.php on line 23
  NULL 
  Notice: Trying to get property of non-object in C:\xampp\htdocs\xampp\provisioning\index.php on line 24
  </code></pre>
  
  <p>My FULL CODE can be found on <a href="http://pastebin.com/12HiHEcu" rel="nofollow">http://pastebin.com/12HiHEcu</a> , it's my last try which is not working  :(</p>
  
  <p>Can somebody help me to fix it?</p>