Lasso Soft Inc. > Home

[ xml_node->extract ]

Method

The [xml_node->extract] method retrieves all of the child nodes of the given node which have the specified tag name.

The method requires one parameter which is the name of the tag to retrieve. 

[xml_node->extract] returns a [staticarray] object containing a list of [xml_element] objects.

This method is similar to [xml_element->getelementsbytagname] but it only returns matchs from immediate children of the xml_node in question.

  • Syntax
xml_node->extract( 'tag_name' )
Examples
  • Beginner

Retrieve all of the first children of an xml_node with a specific tag name

This example uses the [xml_node->extract] method to retrieve the <date> elements from an xml_node. Note that the method ignores the <date> element in the <data> node.

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>') )

var ( myDates = $aMonth->extract('date'))
$myDates

Result

staticarray(<date>4</date>, <date>11</date>, <date>16</date>, <date>23</date>, <date>30</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