我有這樣的XML:的SimpleXML的XPath檢索屬性,而不是文本值
<root>
<parent>
<child id="childAtt">
<subChild id="subAtt">Value to retrieve</subChild>
</child>
</parent>
</root>
目前我試圖用這個XPath來檢索subChild的文本值:
$total = $xml->xpath("/*//child[@id='childAtt']/subChild[@id='subAtt']");
然而,這將返回subChild
屬性值而不是節點的文本值。
我想知道如何檢索subChild
的文本值,其編號爲subAtt
。