XMLTools - Maple Programming Help

Home : Support : Online Help : Connectivity : Web Features : XMLTools : XMLTools/GetChild

XMLTools

 GetChild
 access a child node of an XML tree

 Calling Sequence GetChild(xmlTree, n)

Parameters

 xmlTree - Maple XML tree; XML element n - positive integer; which child to extract from the XML element

Description

 • 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.

Examples

 > $\mathrm{with}\left(\mathrm{XMLTools}\right):$
 > $x≔\mathrm{XMLElement}\left("a",\left[\right],\mathrm{XMLElement}\left("first"\right),\mathrm{XMLElement}\left("second"\right),\mathrm{XMLElement}\left("third"\right)\right):$
 > $\mathrm{Print}\left(x\right)$

 > $\mathrm{Print}\left(\mathrm{GetChild}\left(x,2\right)\right)$

 > $\mathrm{Print}\left(\mathrm{GetChild}\left(x,3\right)\right)$

 > $x≔\mathrm{XMLElement}\left("a",\left[\right],\mathrm{XMLElement}\left("first"\right),\mathrm{XMLElement}\left("second",\left[\right],"text",\mathrm{XMLElement}\left("foo"\right),"more text"\right),\mathrm{XMLElement}\left("third"\right)\right):$
 > $\mathrm{Print}\left(x\right)$
           text          more text
 > $\mathrm{Print}\left(\mathrm{GetChild}\left(x,2\right)\right)$
   text      more text