The [xml_element->hasattribute] method is used to test for the existence of a particular attribute in an xml_element
The method has one required parameter, the name of the attribute to test for. Returns true it the attribute is present, false otherwise.
if( xml_element->hasattribute( 'attribute_name' ) ) => {^ ^}
This example uses the [xml_element->hasattribute] method to verifiy that the 'vacation' xml_element has the weekday element. if not it uses the day and month attributes to set it.
Code
var(vacationDays = xml('<vacation day="23" month="March">
<employee>Sean</employee>
</vacation>') )
if( !$vacationDays->hasattribute('weekday') ) => {^
local( 'weekday' = date($vacationDays->getattribute('month')+' '+$vacationDays->getattribute('day')+' '+date->year, -format="%B %d %Y") )
$vacationDays->setattribute('weekday', #weekday->format("%A"))
^}
'weekday is '+$vacationDays->getattribute('weekday')
Result
weekday is Wednesday
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