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 ALSOxmlTreeGetDoc
,
xmlTreeGetRootElement
,
xmlTreeGetChildren
,
xmlTreeGetFirstChild
,
xmlTreeGetNext
,
xmlTreeGetPrevious
,
xmlTreeGetParent
,
xmlTreeGetFirstAttribute
,
xmlTreeGetAttributes
,
xmlTreeGetNs
,
xmlTreeGetNsDef
,
xmlTreeLookupNsPrefix
,
xmlTreeLookupNsURI