I would like to check this :
I have a valid DOMXPath handler $xpath based on a valid XML DOMDocument, and a string $urlpart.
The XML document has basically this structure :
Code: Select all
<forest>
<tree id="treeID">
<url>tree URL</url>
<branch>
<url>branch URL 1</url>
</branch>
<branch>
<url>branch URL 2</url>
</branch>
...
</tree>
<tree>
...
</tree>
...
</forest>Is the following correct
Code: Select all
$treeid = $xpath->query("//tree[.//url[.='{$urlpart}']][1]/@id");
Thanks for your help !