Traversing the Tree

XML trees are very inter-linked documents. There are functions for getting children (like xmlTreeGetChildren()), getting various siblings (xmlTreeGetNext()), and the parent (xmlTreeGetParent()).

Attributes exist outside of the normal hierarchy. You can get all (or specific) attributes with xmlTreeGetAttributes(), or you can begin iterating over them with xmlTreeGetFirstAttribute().

Namespaces also exist outside of the normal hierarchy. See the Using Namespaces (here) section for more information.


EXAMPLE

<capture>
<rootNode><name>John Doe</name><age>34</age></rootNode>
</capture><$xmlRaw = $ret>
<$doc = (xmlTreeNewDocFromString($xmlRaw))>
<$root = (xmlTreeGetRootElement($doc))>
<$name = (xmlTreeGetChildren($root, 'name'))>
<$nameText = (xmlTreeGetContent($name))>
<$age = (xmlTreeGetNext($name))>
<$ageText = (xmlTreeGetContent($age))>
name is $nameText, age is $ageText


SEE ALSO
xmlTreeGetDoc, xmlTreeGetRootElement, xmlTreeGetChildren, xmlTreeGetFirstChild, xmlTreeGetNext, xmlTreeGetPrevious, xmlTreeGetParent, xmlTreeGetFirstAttribute, xmlTreeGetAttributes, xmlTreeGetNs, xmlTreeGetNsDef, xmlTreeLookupNsPrefix, xmlTreeLookupNsURI


Copyright © Thunderstone Software     Last updated: Dec 10 2018
Copyright © 2019 Thunderstone Software LLC. All rights reserved.