help with xpath selecting
Posted
by fayer
on Stack Overflow
See other posts from Stack Overflow
or by fayer
Published on 2010-03-18T01:48:12Z
Indexed on
2010/03/18
1:51 UTC
Read the original article
Hit count: 425
i've got an id attribute value for an element.
i want to select only its children (not all descendants).
i used $childElements = $xml->xpath('//entity[@id=212323]'); print_r($childElements);
but that would select ALL descendants and print them out. i just want to select the 1 generation children. how could i do that?
<entity id=212323>
<this>asd</this>
<this>asd</this>
<this>asd</this>
<this>
<notThis>asd</notThis>
<notThis>asd</notThis>
<notThis>asd</notThis>
</this>
</entity>
© Stack Overflow or respective owner