SiteScope User's Guide


Monitoring XML Documents

SiteScope's content matching capabilities is an important feature in monitoring networked information systems and content. For SiteScope monitors that provide content matching, the basic content matching is available through the use of PERL regular expressions. SiteScope also includes the capability of matching document content by traversing XML documents. For example, you can include an XML match content string using the URL Monitor and Web Services Monitor to match an XML element name, an attribute of an XML element, or the content of an element. You can use this to check for content in XML based Web pages, SOAP or XML-RPC documents, and even WML pages served to WAP enabled devices.

This section describes:

Understanding Content Matching for XML Documents

The syntax of XML match content strings reflects the hierarchal structure of the XML document. Match content strings that start with "xml." are recognized as element names within an XML document. The element names are added, separated by periods, in the order of their relationship to the root element. For example, in the document weather.xml the root element is <weather>. This element includes child elements named <area>, <skies>, <wind>, <forecast>, and so forth. To access the content of these XML elements or their attributes you would use a syntax like xml.weather.area.

To check that specific content or value is present, add an equals sign after the element name whose content you are testing and then add the value of the content. If there are multiple instances of an element name in the document you can check a particular instance of that element by adding the number indicating the order of the element in the document in square brackets (see the example in the table below). You can also test for multiple elements or values by separating individual search strings with commas. The table below gives several examples of the syntax used to match content in XML documents

Example Match Content

Description

xml.weather.temperature Succeeds if any <weather> node in the document contains one or more <temperature> elements. The content of the <temperature> element(s) is/are returned by the monitor. If no <temperature> element is found within the <weather> node, an error is returned.
xml.weather.temperature=20 Succeeds if any <weather> node in the document contains one or more <temperature> element where the content of the <temperature> element equals 20. The content of the <temperature> element is NOT returned by the monitor if the match is found. An error is returned if no <temperature> element is found within the <weather> node or if no <temperature> element contains the value 20.
xml.weather.forecast.[confidence] Succeeds if any <weather> node in the document contains a <forecast> element that has an attribute called confidence. The value of the confidence attribute is returned by the monitor if the match is found. An error is returned if no <forecast> element is found within the <weather> node or if no confidence attribute is found.
xml.weather.forecast[3].[confidence]=50 Succeeds if any <weather> node in the document contains three or more <forecast> elements where the third <forecast> element has a confidence attribute with a value of 50. An error is returned if the <weather> node has fewer than three <forecast> elements or if the value of the confidence attribute is not equal to 50.
xml.weather.temperature=20, xml.weather.skies=rain Succeeds if any <weather> node in the document contains one or more <temperature> element where the content of the <temperature> element equals 20 AND if any <weather> node contains one or more <skies> element where the content of the <skies> element equals rain. Returns an error if either of the matches fails.
xml.wml.card.p.table.tr.td.anchor=Home Page Checks the content of <anchor> elements in the designated path of a WML document. Succeeds if any <card> node containing table cells with one or more <anchor> element where the content of any of the <anchor> elements equals "Home Page"

Using XML Content Match Values in Monitor Configurations

Monitors like the URL Monitor have a content match value that is logged to the SiteScope monitor data log and can also be used to set error and warning status thresholds for the monitor. The values of the XML names are saved as the content match values for the monitor.

For example, if the match content expression was
xml.weather.temperature
and the document was the contents of the file weather.xml then the content match value would be:
46

You can then set the error, warning, and good status thresholds in the Advanced Options section for the monitor to compare your specific thresholds to the value returned by the content match.

For example, if you were monitoring temperature values and wanted to be alerted when the temperature value dropped below 72 degrees you could set the monitor status thresholds as follows:

Error if
Warning if
Good if

With this configuration the monitor would check the content of the temperature element and then compare it to the error and warning thresholds. In the example we have used here, the status of the monitor would be an error because the temperature value is 46 which is less than 72.