The behavior of this context is to iterate the child XML nodes of a parent node.

[xmlnodes ref=...&path=...&name=...&exact=T/F] <WebDNA>[/xmlnodes]

Parameters:

· ref - Reference to an xml parsed object variable. If this parameter is not provided, then it is assumed that there is an 'outer' [xmlnodes] context from which to reference a particular XML node. (This is explained further on in this tutorial).

· path - Depending on which path method is used (see below), this will either be a path to the parent xml element (node) from which to iterate the child elements (nodes), or a path 'expression' representing a collection of XML nodes. If a path is not provided, then the child nodes of the 'ref' node will be iterated

· name - A string used to filter the resulting xml nodes. Only the xml nodes that match the 'name' string will be iterated.

· exact - Used with the 'name' parameter. Either 'T' or 'F'. Specifies whether the 'name' parameter is a 'whole' string match or a 'sub-string' match.

· [value] - The value of the current iterated XML node. Will be empty if the node is a 'container' node, i.e. contains other XML nodes.

· [index] - The 'count' of the current iterated node.

· [numfound] - The total 'count' of iterated nodes.

· [content] - The 'raw' xml content of the current node.

· [iscontainer] - 'T' if the current node contains other XML nodes.

The default behavior of this context is to iterate the child XML nodes of a parent node. The location of the parent node, in the xml 'tree', is determined by the 'path' parameter. If a path parameter is not provided, then the child nodes of the ' ref 's root are iterated.

The path parameter can take three different forms: 'named:', 'indexed:', or 'xpath:'.

- The 'named:' method expresses a literal path to the parent node, i.e. 'path=named:CATALOG/CD(n)'. If there are more than one similarly named 'sibling' nodes, then the '(n)' part specifies which node to select as part of the path.

- The 'indexed:' method expresses an numerical 'step' wise path to the parent node, i.e. 'path=indexed:1/2/3'. This example could be expressed as: 'The third child node of the second child node of the first child node of the xml root'.

- The 'xpath:' method is an XPath 'expression' that evaluates to a collection of nodes in the XML tree. In this case, the iterated nodes are those of the resulting 'collection' of nodes. This is a bit different from the 'named' and 'indexed' method in that the collection of node are not the 'child' nodes of a given 'parent' node. This is the most powerful method for selecting XML nodes. There are several online 'xpath' tutorials that you can visit that will help you develop your XPath skills.

We will be using the 'named' method later in this tutorial page.

Now lets use the[xmlnodes]context to iterate the xml child nodes of the root xml node of the 'example1.xml' document.

We see that the 'CATALOG' node is the only child node from the root of the xml file. Notice that the 'value' is empty. This is because the 'CATALOG' node has no value, and is actually a 'container' node for other xml nodes. So a 'value' will only be displayed for a 'leaf' xml node, i.e.

JOHN

In this case, [name] would evaluate to 'FIRSTNAME' and [value] would be 'JOHN'.

Lets dive a little deeper into the xml file and iterate the 'child' nodes of the root 'catalog' node of the example1.xml file...

Now we are getting some interesting results. Note that the 'inner' xmlnodes context did not need a 'ref' parameter. This is because the inner xmlnodes context inherited the outer xmlnodes' current iterated node. Also notice that the inner xmlnodes context did not use a 'path' parameter. So it uses the 'root' path of the outer xmlnodes' current iterated node.

Did you also notice the use of the [index] tag in the outer xmlnodes context? As with most 'iterative' WebDNA contexts, the [index] tag resolves to the current iteration 'count'.

Lets refine the named path parameter to go directly to a particular 'CD' node.

With a minor change to the 'path' parameter, we can retrieve all the child nodes of the fifth 'CD' node of the example1.xml file...