Lasso Soft Inc. > Home

[ xml_attr->ownerelement ]

Method

Returns the xml_element that the attribute belongs to.

  • Syntax
xml_attr->ownerelement
Examples
  • Beginner

Retrieve the XML element that an attribute belongs to.

This example loops through some XML and outputs a list of the attributes along with the xml elements they belong to.

Code

var( rhinos = xml('<rhinos>
     <rhino class="coder">Jordon</rhino>
     <rhino class="coder" type="lead">Jono</rhino>
     <rhino class="writer">Rachel</rhino>
</rhinos>') )

local( c = $rhinos->childNodes )

loop(#c->length) => {
     local( myNode = #c->item( loop_count - 1 ) )
     local( atts = #myNode->attributes )
     #atts->forEach => {^
          'The attribute '+#1->name+'='+#1->value+' is in the element: '+#1->ownerelement+'\n'
     ^}
}

Result

The attribute class=coder is in the element: <rhino class="coder">Jordon</rhino>
The attribute class=coder is in the element: <rhino class="coder" type="lead">Jono</rhino>
The attribute type=lead is in the element: <rhino class="coder" type="lead">Jono</rhino>
The attribute class=writer is in the element: <rhino class="writer">Rachel</rhino>

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