GetChild - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


XMLTools

  

GetChild

  

access a child node of an XML tree

 

Calling Sequence

Parameters

Description

Examples

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

withXMLTools:

xXMLElementa,,XMLElementfirst,XMLElementsecond,XMLElementthird:

Printx

<a>
  <first/>
  <second/>
  <third/>
</a>

PrintGetChildx&comma;2

<second/>

PrintGetChildx&comma;3

<third/>

xXMLElementa&comma;&comma;XMLElementfirst&comma;XMLElementsecond&comma;&comma;text&comma;XMLElementfoo&comma;more text&comma;XMLElementthird&colon;

Printx

<a>
  <first/>
  <second>
    text
    <foo/>
    more text
  </second>
  <third/>
</a>

PrintGetChildx&comma;2

<second>
  text
  <foo/>
  more text
</second>

See Also

XMLTools

XMLTools[ContentModelCount]

XMLTools[FirstChild]

XMLTools[HasChild]

XMLTools[Print]

XMLTools[RemoveChild]

XMLTools[XMLElement]