得到節點我有xml文件:的SimpleXML通過屬性
<?xml version="1.0" ?>
<xml>
<opis lang="en">My text</opis>
<opis lang="cz">My text2</opis>
</xml>
我想 「我的文本2」 - 這樣一個節點,在屬性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
)
}
))
的可能重複[SimpleXML的:選擇具有一定屬性值的元素(http://stackoverflow.com/questions/992450/simplexml-selecting-元素,它具有一定的屬性值) – hakre