The [xml_element->setattribute] method sets the value of the named attribute of an xml_element.
This method requires two string parameters. The first is the name of the attribute to set, the second is the value of the attribute.
If the named attribute is not present in the element [xml_element->setattribute] will add it to the element.
xml_element->setattribute( 'attribute_name', 'value' )
Use the [xml_element->setattribute] method.
This example shows how to change the "day" attribute of the "vacation" xml_element.
Code
var(vacationDays = xml('<vacation day="23" weekday="Friday"><employee>Sean</employee></vacation>') )
'Day is '+$vacationDays->getattribute('day')+'\n'
//change the value
$vacationDays->setattribute('day', '21')
'Day is '+$vacationDays->getattribute('day')
Result
Day is 23 Day is 21
This example shows how to add an attribute called "month" with the value "March" to the "vacation" xml_element above.
Code
$vacationDays->settattribute('month', 'March')
$vacationDays
Result
<vacation day="21" weekday="Friday" month="March"> <employee>Sean</employee> </vacation>
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 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments