Tinderbox v9 Icon

Stream.xml.each(path){action}


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Altered: 

 Function   [other Function type actions]

 Item   [operators of similar scope]

 Stream parsing   [other Stream parsing operators]

 9.1.0

 


Stream.xml.each(path){ action(s) }

This operator locates the XML object for each object at the path. Invokes the action block with the xml item bound in turn to each book element. On completion, it restores the XML object to its previous state.

Inside the action clause, action code can refer to the value of the iterated item as xml[], and the attribute of that item as xml[@attribname], 'attribname' being the name of an attribute of the XML object in focus.

Consider this source stream:

<shelf>
<book price="9.95">War and Peace</book>
<book price="4.95">No et Moi</book>
<audio price="14.95">Born To Run</book>
</shelf>

 

Examples

Stream.xml.each("/shelf/book") {action} 

returns every 'book' object in the 'shelf' object and iterates them. For each list item it invokes the action block with the xml item bound in turn to each book element.

On completion, it restores the XML object to its previous state.

Inside the action clause, you can refer to the value of the iterated item as xml[], and the attribute of that item as xml[@attribname].