我有xml文件:
<?xml version="1.0" ?>
<xml>
<opis lang="en">My text</opis>
<opis lang="cz">My text2</opis>
</xml>
我想得到“我的 text2” - 所以属性 lang 是“cz”的节点:
$xml = simplexml_load_file($fileName);
$result = $xml->xpath('//xml/opis[@lang="cz"]')
但我得到的不是价值:
array(1) (
[0] => SimpleXMLElement object {
@attributes => array(1) (
[lang] => (string) cz
)
}
))