get parent elements in xml with simplexml in php?

Posted by fayer on Stack Overflow See other posts from Stack Overflow or by fayer
Published on 2010-03-17T21:46:09Z Indexed on 2010/03/17 21:51 UTC
Read the original article Hit count: 461

Filed under:
|
|

with $element->children() i cant get all the child elements of current element.

but how can i get all the parent elements for current element with simplexml?

lets say it looks like this:

<entity id=1>
   <name>apple</name>
   <entities>
      <entity id=2>
         <name>mac</name>
         <entities>
            <entity id=3>
               <name>safari</name>
            </entity>
         </entities>
      </entity>
   </entities>
</entity>

if my current $element is id=3, i want to get the mac and apple entity ids.

is this possible with simplexml cause i cant find any function allowing me to do this?

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml