PHP读取XML节点问题

2025-06-21 14:47:55
推荐回答(1个)
回答1:

假定这个xml是一个字串 $xml

$xml = new SimpleXMLElement($xml);

$autoPlay = $xml->attributes()->autoPlay;
$autoNextSong = $xml->attributes()->autoNextSong;

这样你获取的会是两个对象, 如果需要用来做某些特定的事情, 比如显示

echo (string)$autoPlay;