XML:
<A>
<B type="source">
<C>
<D>
<E ref="description">my_desc</E>
<E>Some other E</E>
</D>
</C>
</B>
</A>
PHP:
$doc = new SimpleXMLElement('URL.xml', null, true);
$path = $doc->xpath('A/B[@type="source"]/C/D/E[@ref="description"]');
var_dump ($path);
回报:
Array
(
)
最终,我试图<E>
用ref="description"
. 我究竟做错了什么?以下指南来自: http: //php.net/simplexmlelement.xpath