title: PHP XML XPATH node element iteration and inserting into array
body: <p>Ok, so I thought I had this nailed , but sadly not . I have this XML:</p>
  
  <pre><code>//XML
  this is root--&gt; &lt;story&gt; 
  &lt;article&gt;
  &lt;title&gt;my title &lt;/title&gt;
  &lt;img&gt;my image &lt;/img&gt;
  &lt;link&gt;my link &lt;/link
  &lt;/article&gt;
  &lt;/story&gt;
  </code></pre>
  
  <p>and then this PHP:</p>
  
  <pre><code>//php
  $dom = new DOMDocument('1.0', 'UTF-8');
  $dom-&gt;loadXML($_SESSION['xml']);
  $xpath = new DOMXPath($dom);
  $query = $xpath-&gt;query('//section/article');
  
  foreach($query as $article  ):
                  $currentTitle = $article-&gt;title ;
  //edit - mistake in code - $article used for all 
                  //$imagearray =  $currentimg-&gt;img ;
                  //$linkarray =  $currentlink-&gt;link ;
                  array_push( $availAds,$currentTitle,$imagearray,$linkarray );
          endforeach;
  </code></pre>
  
  <p>So what I'm trying to do is get the 'Title' 'Img' and 'Link' values and insert them into a pre existing array. The array already outputs fine with the previously entered values, but  I then need to be able to output the results of the updated array in this way:</p>
  
  <pre><code>    printf(
                      '&lt;input name="ads[%1$s][title]" value="%2$s" style="width:310px;" /&gt;&lt;br /&gt;',
                      $availAd['image'],
                      $availAd['title']
                  );
  </code></pre>
  
  <p>The issue is right now , the foreach returns NULL for $currentTitle , $imagearray and $linkarray</p>