我有api链接。当我调用此链接时,该链接将输出xml数据。
out put是
<note>
<something a="this is a" b="this is b" c="this is c">
<something a="this is a1" b="this is b1" c="this is c1">
<something a="this is a2" b="this is b2" c="this is c2">
<something a="this is a3" b="this is b3" c="this is c3">
</note>
我想获得某些属性,我如何用php编写。 我是php的初学者。感谢我的朋友。
我想写如下图所示。 我知道这个PHP代码有问题,如何正确编写。
foreach($xml->something[0]->attributes() as $a => $b)
{
echo $a,'="',$b,"\"</br>";
}
?>
答案 0 :(得分:0)
你可以试试这个
$xml = simplexml_load_string($string);
foreach($xml->foo[0]->attributes() as $a => $b) {
echo $a,'="',$b,"</br>";
}