PHP xml解析,不确定这个术语是什么


PHP xml parsing, not sure what the term is for this

<guid isPermaLink="true">/125843</guid>

我该如何从中得到"真实"?老实说,我现在想不出它的名字了。。不能是命名空间。。

http://www.php.net/manual/en/simplexmlelement.attributes.php

猜测您使用的是SimpleXML,因为您没有命名Parser。

这是XML元素的一个属性。您可以使用SimpleXML在PHP中解析XML。(它有一个相当简单的API)

您可以使用xpath来获取属性

$xmlstr = '<guid isPermaLink="true">/125843</guid>';
$xml = simplexml_load_string($xmlstr);
$ispermalink = $xml->xpath('/guid[@isPermaLink]');
foreach ($ispermalink[0]->attributes() as $k => $v) {
    print "isPermaLink... $v 'n";
}