XMLTools - Maple Programming Help

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

XMLTools

 GetChildByName
 access a child node of an XML tree

 Calling Sequence GetChildByName(xmlTree, name)

Parameters

 xmlTree - Maple XML tree; XML element name - string or symbol; the name of the child element to extract

Description

 • The GetChildByName(xmlTree, name) command accesses the children of the given XML element xmlTree with element name equal to name. A list of all children that are elements with element type equal to name is returned.

Examples

 > $\mathrm{with}\left(\mathrm{XMLTools}\right):$
 > $\mathrm{xmlTree}≔\mathrm{XMLElement}\left("a",\left[\right],\left[\mathrm{XMLElement}\left("b",\left[\right],"b text"\right),\mathrm{XMLElement}\left("c",\left[\right],"c text"\right),\mathrm{XMLElement}\left("b",\left[\right],"more b text"\right)\right]\right):$
 > $\mathrm{Print}\left(\mathrm{xmlTree}\right)$
   b text   c text   more b text
 > $\mathrm{map}\left(\mathrm{Print},\mathrm{GetChildByName}\left(\mathrm{xmlTree},"b"\right)\right)$
 b text more b text
 $\left[{}\right]$ (1)
 > $\mathrm{map}\left(\mathrm{Print},\mathrm{GetChildByName}\left(\mathrm{xmlTree},"c"\right)\right)$
 c text
 $\left[{}\right]$ (2)
 > $\mathrm{map}\left(\mathrm{Print},\mathrm{GetChildByName}\left(\mathrm{xmlTree},"nosuchelement"\right)\right)$
 $\left[{}\right]$ (3)