XMLTools
GetChild
access a child node of an XML tree
Calling Sequence
Parameters
Description
Examples
GetChild(xmlTree, n)
xmlTree
-
Maple XML tree; XML element
n
positive integer; which child to extract from the XML element
The GetChild(xmlTree, n) command accesses the child of the given XML element xmlTree at position n. The returned expression is either of type string or an XML tree data structure (when the child node has a tree structure of its own).
Child elements are numbered sequentially in the order they appear in the element. Attributes that might also be present in the element are not counted in the positioning. Therefore, the expressions GetChild(xmlTree, n) and GetChild(ContentModel(xmlTree ), n) return the same result. (The first form is slightly more efficient.)
The procedure that contains the GetChild command must verify if the child index n is valid.
with⁡XMLTools:
x≔XMLElement⁡a,,XMLElement⁡first,XMLElement⁡second,XMLElement⁡third:
Print⁡x
<a> <first/> <second/> <third/> </a>
Print⁡GetChild⁡x,2
<second/>
Print⁡GetChild⁡x,3
<third/>
x≔XMLElement⁡a,,XMLElement⁡first,XMLElement⁡second,,text,XMLElement⁡foo,more text,XMLElement⁡third:
<a> <first/> <second> text <foo/> more text </second> <third/> </a>
<second> text <foo/> more text </second>
See Also
XMLTools[ContentModelCount]
XMLTools[FirstChild]
XMLTools[HasChild]
XMLTools[Print]
XMLTools[RemoveChild]
XMLTools[XMLElement]
Download Help Document