This article applies as of PRTG 22
How exactly do I extract values from an XML node using the HTTP XML/REST Value sensor of PRTG?
Extracting XML nodes
The HTTP XML/REST Value sensor can parse different XML outputs. The notation is XPath compatible. See a typical simple XML example below:
<data>
<section1>
<name>int. Temperature</name>
<value_float>36.31</value_float>
<value_int>3631</value_int>
<value_string>thirty-six</value_string>
<minimum>36.25</minimum>
<maximum>46.87</maximum>
<limit_low>10.00</limit_low>
<limit_high>50.00</limit_high>
<function>l</function>
<alarm1>0</alarm1>
</section1>
</data>
Data from nested XML tags
To obtain values from nested XML tags, use tag names separated by a slash. For example, to obtain the float value 36.31 from the XML above, you would use the following value in the sensor's XML Node field:
section1/value_float
When there are multiple nodes within a XML result, you can reference it's occurrence using a number between Brackets.
The following PRTG API Call For example:
/api/table.xml?content=sensors&output=xml&columns=name,uptime&id=DEVICEID
Produces the following output:
<?xml version="1.0" encoding="UTF-8"?>
<sensors totalcount="2" listend="1">
<prtg-version>15.2.18.2816</prtg-version>
<item>
<name>Ping</name>
<uptime>95,3760%</uptime>
<uptime_raw>000000000953760</uptime_raw>
</item>
<item>
<name>Traceroute Hop Count</name>
<uptime>95,4608%</uptime>
<uptime_raw>000000000954608</uptime_raw>
</item>
</sensors>
If we want to read the uptime for the Traceroute Hop Count in the XML result, we use the following syntax within the XML Node (and optional property) inside PRTG:
item[2]/uptime
That will result in the folowing output within the HTTP XML/REST Value Sensor in PRTG
Node item[2]/uptime_raw holds value 95,4608%.
More
Disclaimer:
The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.