TANDBERG MPS API

User Guide

1.2Introduction to XML Path Language (XPath)

XPath is a comprehensive language to address data in XML documents.

It is though very simple to understand the basics. If you are able to specify the path to a file on your computer, you are able to specify the path to an element in a XML structure.

Example 1.5

Let us go back to the serial port configurations of Example 1.1.

<Configuration> <SerialPort item="1">

<BaudRate item="1">9600</BaudRate> <Parity item="1">None</Parity> <DataBits item="1">8</DataBits> <StopBits item="1">1</StopBits> <Mode item="1">Control</Mode>

</SerialPort>

</Configuration>

To specify the path to the SerialPort element we simply start at the root level and separate the levels in the tree structure by a slash (“/”):

Configuration/SerialPort

The path to the BaudRate element is:

Configuration/SerialPort/BaudRate

Example 1.6

To address a specific item of an element, the item number is added within brackets (“[]”) after the element name.

The path to the BaudRate element of SerialPort item 2 in Example 1.4 is: Configuration/SerialPort[2]/BaudRate

If the item number is omitted for an element, all items of this element will be addressed. The following expression addresses the BaudRate element of both serial ports: Configuration/SerialPort/BaudRate

Example 1.7

When using XPath it is possible to omit specifying intermediate levels in the address expression. By using the powerful “double slash” you can address elements without having to specify the complete path.

The expression below addresses the BaudRate element of both serial ports of Example 1.4:

Configuration//BaudRate

5

Page 7
Image 7
TANDBERG D13639 manual Introduction to XML Path Language XPath