# XML Peek

### XMLPeek <a href="#xmlpeek" id="xmlpeek"></a>

The **XMLPeek** function allows one or more XML nodes to be read from an XML document.

### Properties <a href="#properties" id="properties"></a>

#### XML Source <a href="#xml-source" id="xml-source"></a>

XML source controls where the function reads the input XML from, and must be one of the following values:

1. File\
   Reads from the XML file defined in the [XML File](#xml-file) property
2. String\
   Reads from an XML formatted string defined in the [XML String](#xml-string) property.

#### XML File <a href="#xml-file" id="xml-file"></a>

The path to an XML file which will be read by the function.

This property is only displayed if [XML Source](#xml-source) is set to "File".

#### XML String <a href="#xml-string" id="xml-string"></a>

The XML formatted string to read.

This property is only displayed if [XML Source](#xml-source) is set to "String".

#### XPath <a href="#xpath" id="xpath"></a>

XPath is a string conforming to the [XML path language](http://en.wikipedia.org/wiki/XPath) format. It is used to select which nodes are read by the function.

#### Namespaces <a href="#namespaces" id="namespaces"></a>

An optional string defining any [XML namespaces](http://en.wikipedia.org/wiki/XML_Namespace) for prefixes used in the [XPath](#xpath) property.

Namespaces should be defined in the format \[prefix]="\[URI]".

Multiple definitions should be separated by a space.

#### Output <a href="#output" id="output"></a>

Output controls how the nodes matched by *Xpath* are returned from the functions. Output can be set to one of the following values:

1. Loop nodes\
   The function will return the contents of each matched node one item at a time. On the design canvas you will see a "ForEachNode" loop icon as a child of this function. Any function added to the loop will be able to access the contents of the node in an output variable named "Node".
2. List of nodes\
   The function will produce a list containing the contents of all matching nodes.
3. Single node\
   The function will provide as output the contents of the first matched node.\
   If more than one node is matched by XPath, only the first one is returned.\
   If no matching nodes are found, an exception is thrown.
4. Single node or empty\
   The function will provide as output the contents of the first matched node, if one was found.\
   If more than one node is matched by XPath, only the first one is returned.\
   If no matching nodes are found, the output will contain an empty string.

### Definition <a href="#definition" id="definition"></a>

Data is stored in the following variables:

When *Output* is 'List of nodes':

* XMLPeek (List \<String>)

When *Output* is 'Single node' or 'Single node or empty':

* XMLPeek (String)

When *Output* is 'Loop nodes':

* XMLPeekForEachNode
  * Index (Int32)
  * String (String)

### Links <a href="#links" id="links"></a>

[Wikipedia: XML](http://en.wikipedia.org/wiki/XML)

[Wikipedia: XML Path Language](http://en.wikipedia.org/wiki/XPath)

[Wikipedia: XML Namespaces](http://en.wikipedia.org/wiki/XML_Namespace)
