TANDBERG D14172.01 manual Introduction to XML Path Language XPath, Example

Models: D14172.01

1 84
Download 84 pages 8.98 Kb
Page 6
Image 6
1.2Introduction to XML Path Language (XPath)

TANDBERG Gatekeeper/Border Controller API User Guide

1.2Introduction to XML Path Language (XPath)

XPath is a comprehensive language to address data in XML documents. It is, however, 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 SNMP configuration of Example 1.1:

<Configuration> <SNMP item="1">

<Mode item="1">On</Mode>

<CommunityName item="1">public</CommunityName> <SystemContact item="1">Administrator</SystemContact> <SystemLocation item="1"></SystemLocation>

</SNMP>

</Configuration>

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

Configuration/SNMP

The path to the CommunityName element is:

Configuration/SNMP/CommunityName

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 Address element of Server item 2 in Example 1.4 is:

Configuration/IP/DNS/Server[2]/Address

If the item number is omitted for an element, all items of this element will be addressed. The following expression addresses the Address element of all DNS servers:

Configuration/IP/DNS/Server/Address

D14172.01

page 6 of 84

Page 6
Image 6
TANDBERG D14172.01 manual Introduction to XML Path Language XPath, Example