cts.elementWalk( node as Node, element as xs.QName[], callback as function(NodeBuilder, node()) as xs.string?, builder as NodeBuilder ) as null
Returns a copy of the node, replacing any elements found with the specified expression.
The arguments to the callback function provide context for the element match.
builder
asNodeBuilder
An Node builder that is building the highlighted node copy. Whatever the callback adds to the builder will be added to the final copy.
node
aselement()
The matching element node.
The return from the callback function is an action that specifies what happens next:
// // Replace every 'name' element with the text "Mary" // var x = new NodeBuilder(); x.startElement("p"); x.addText("Dear "); x.startElement("name"); x.endElement(); x.addText( ", thank you for your interest."); x.endElement(); var result = new NodeBuilder(); cts.elementWalk(x.toNode(), xs.QName("name"), function(builder,node) { builder.addText("Mary") }, result ); result.toNode() => <p>Dear Mary, thank you for your interest.</p>