Lasso Soft Inc. > Home

[ xml_element->getelementsbytagname ]

Method

The [xml_element->getelementsbytagname] method is used to retrieve all of the elements of an xml object whose tag name matches the parameter.

The method takes one parameter, the tag name to search for. 

[xml_element->getelementsbytagname] returns an [xml_nodeList] object which contains a set of [xml_element] objects.

The method returns an empty object if the specified tag name is not found.

  • Syntax
xml_element->getelementsbytagname( 'tag_name' )
Examples
  • Beginner

Retrieve all of the instances of a given tag from an xml_element

This example shows how to use the [xml_element->getelementsbytagname] method to retrieve all of the <date> elements from an XML object.

Code

var(aDay = xml('<day weekday="Monday">
    <month>
        <name>March</name>
        <date>4</date>
        <date>11</date>
        <date>16</date>
        <date>23</date>
        <date>30</date>
    </month>
</day>') )

$aDay->getelementsbytagname('date')

Result

xml_nodeList(<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