我有这个
<rss>
 <channel>
  <item>
   <link>http://www1</link>
   <title>Doe </title>
   <description>Para  </description>
  </item>
 </channel>
</rss>
和这个
<feed>
 <article>
   <link>http://www1</link>
   <title>Doe </title>
   <description>Para  </description>
 </article>
</feed>
如何使用相同的代码来处理这两种 xml。
我试试这个但不起作用
$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->$xml_root->$xml_item as $xmltree){
I received this: Warning: Invalid argument supplied for foreach() in
I try use
foreach ($xmldoc->$xml_root()->$xml_item() as $xmltree){
but doesn't work too
请帮帮我!!