Lasso Soft Inc. > Home

[ xml_node->childNodes ]

Method

The  [xml_node->childNodes] method returns an xml_nodeList of all of the immediate children of the named xml_node.

Note: the items of the resulting list are indexed starting at 0.

  • Syntax
xml_node->childNodes
Examples
  • Beginner

Get a list of the all the child nodes of an xml_node

This example uses the [xml->childNodes] method to drill down into the first child node of the XML node "month" to retrieve the node containing the last day of the month. Notice the indexing that is used in the [xml_nodeList->item] method to retrieve the desired xml_element.

Code

var(aMonth = xml('<month>
    <data>
        <name>March</name>
        <date type="lastDay">31</date>
    </data>
    <date>4</date>
    <date>11</date>
    <date>16</date>
    <date>23</date>
    <date>30</date>
</month>') )

'The child nodes are: \n'+$aMonth->childNodes()+'\n\n'

var( theMonth = $aMonth->childNodes->item(0) )

'The Month is: \n'+$theMonth+'\n\n'

var( lastDay = $theMonth->childNodes->item(1) )

'The lastDay is '+$lastDay

Result

The child nodes are: 
xml_nodeList(<data>
  <name>March</name>
  <date type="lastDay">31</date>
</data>, <date>4</date>, <date>11</date>, <date>16</date>, <date>23</date>, <date>30</date>)

The Month is: 
<data>
  <name>March</name>
  <date type="lastDay">31</date>
</data>

The lastDay is <date type="lastDay">31</date>

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft