我的 PHP 代码如下所示,它显示空白我想显示所有带有超链接的记录,如
<a href="test.php?id=$Id">$Name</a>
其中 $Id, $Name 来自 XML 提要
$path = 'www.abc.com/test.xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $path);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$returned = curl_exec($ch);
curl_close($ch);
// $xml === False on failure
$xml = simplexml_load_string($returned);
foreach( $xml->Name as $Name){
print (string)$Name;
}
我的 XML 如下所示
<ABCXml version="1.1.0">
<Manufacturers>
<Item>
<Id>219</Id>
<Name>Matrix Corp</Name>
</Item>
<Item>
<Id>2040</Id>
<Name>Microcomputer</Name>
</Item>
</Manufacturers>
</ABCXml>