xmlnodesattributes

The [xmlnodesattributes] context is used to iterate the attributes of a specific XML node.

Parameters

ParameterDescription
refReference to an xml object variable. If this parameter is not provided, then it is assumed that there is an 'outer' [xmlnode] or [xmlnodes] context from which to reference a particular XML node.
pathPath to the desired XML node. If an XPath expression is used, it should evaluate to a single node.

Tags available within a [xmlnodesattributes] context:

TagDescription
nameThe name of the current iterated XML node attribute.
valueThe value of the current iterated XML node attribute.
indexThe 'count' of the current iterated attribute.
numfoundThe total 'count' of iterated attributes.
The path parameter is used to locate the node. As with the [xmlnodes] context and the [xmlnode] context, the path parameter has three modes; named, indexed and xpath.

The [xmlnodesattributes] context is used to retrieve the attributes of an XML node, the attributes are the parameters of the XML node container.

Example WebDNA code:
This example uses an example file that you can view/download here example-file.xml
<b>Parse the xml file:</b><br>
[xmlparse var=xml_var1][include file=example-file.xml][/xmlparse]
<b>Get the contents of the indexed node:</b><br>
[xmlnode ref=xml_var1&path=indexed:1/1]
  [content]
[/xmlnode]<br>
<b>Display the attributes of the node:</b><br>
[xmlnodeattributes ref=xml_var1&path=indexed:1/1]
  [name] = [value]<br>
[/xmlnodeattributes]
Results:
Parse the xml file:
Get the contents of the indexed node:
<CD status="instock" id="123">
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
Display the attributes of the node:
id = 123
status = instock

To simplify the code, place the [xmlnodesattributes] context 'inside' of the [xmlnode] context. In this case, the 'path' or 'ref' parameters are not required [xmlnodesattributes], as the 'implied' XML node in the outer [xmlnode] context is used.

Example WebDNA code:
This example uses an example file that you can view/download here example-file.xml
[xmlparse var=xml_var1][include file=example-file.xml][/xmlparse]
[xmlnode ref=xml_var1&path=indexed:1/1]
  [xmlnodeattributes]
    [name] = [value]<br>
  [/xmlnodeattributes]
[/xmlnode]
Results:
id = 123
status = instock