title: How use two structures of xml with the same function
body: <p>I have this</p>
  
  <pre><code>&lt;rss&gt;
   &lt;channel&gt;
    &lt;item&gt;
     &lt;link&gt;http://www1&lt;/link&gt;
     &lt;title&gt;Doe &lt;/title&gt;
     &lt;description&gt;Para  &lt;/description&gt;
    &lt;/item&gt;
   &lt;/channel&gt;
  &lt;/rss&gt;
  </code></pre>
  
  <p>and this</p>
  
  <pre><code>&lt;feed&gt;
   &lt;article&gt;
     &lt;link&gt;http://www1&lt;/link&gt;
     &lt;title&gt;Doe &lt;/title&gt;
     &lt;description&gt;Para  &lt;/description&gt;
   &lt;/article&gt;
  &lt;/feed&gt;
  </code></pre>
  
  <p>How can I use the same code to work with this two kinds of xml.</p>
  
  <p>I try this but doesn't work</p>
  
  <pre><code>$xml_root=$_GET['xml_root'];    // $xml_root='channel'
  $xml_item=$_GET['xml_item'];    // $xml_item='item'
  $xml= file_get_contents($xmlfile);
  $xmldoc = new SimpleXmlElement($xml);
  foreach ($xmldoc-&gt;$xml_root-&gt;$xml_item as $xmltree){
  
  I received this: Warning: Invalid argument supplied for foreach() in
  
  I try use
  
  foreach ($xmldoc-&gt;$xml_root()-&gt;$xml_item() as $xmltree){
  
  but doesn't work too
  </code></pre>
  
  <p>Help me Please!!</p>