// makes extracting attribute values easier define xml_attrmap(in::xml_namedNodeMap_attr) => { local(out = map) with attr in #in do #out->insert(#attr->name = #attr->value) return #out } local( text = '
Invisibility Cream 14.50 Makes you invisible Levitation Salve 23.99 Levitate yourself for up to 3 hours per application
Blork and Freen Instameal 4.95 A tasty meal in a tablet; just add water Grob winglets 3.56 Tender winglets of Grob. Just add water
', xml = xml(#text) ) local( items = #xml -> extract('//item'), firstitem = #items -> first, itemattr = xml_attrmap(#firstitem -> attributes), newprices = array ) 'First item:
UPC: ' #itemattr -> find('upc') ' (stock: ' #itemattr -> find('stock') ')
' #firstitem -> extractone('name') -> nodevalue ' [' #firstitem -> extractone('price') -> nodevalue '] (' #firstitem -> extractone('description') -> nodevalue ')

' with item in #items let name = #item -> extractone('name') -> nodevalue let price = #item -> extractone('price') -> nodevalue do { #newprices -> insert(#name + ': ' + (decimal(#price) * 1.10) -> asstring(-precision = 2) + ' (' + #price + ')') } 'Adjusted prices:
' #newprices -> join('
') '

' 'Array with all names:
' #xml -> extract('//name') -> asstaticarray