ph_snapxml PowerHome formula function
Description
Retrieves element data within
an XML string identified by a sequence of 1 or more element names and a specified
instance number
Syntax
ph_snapxml ( as_xml, as_key )
ph_snapxml ( as_xml, as_key, ai_instance )
Argument | Description |
as_xml | String. A string containing XML data whose element
data you would to extract |
as_key | String. An XML element
name identifying the attribute. If you want to fully qualify a
heirarchy of elements, separate element names with a "<" character.
Only the rightmost element name will have its attribute retrieved |
ai_instance | Integer (Optional). The matching instance
number you would like to retrieve. Use a value of 1 to retrieve the
first matching instance. If this parameter is omitted, a value of 1 will be implied |
Return value
String. Returns the data between the opening and closing tags of the tag specified in the as_key parameter. Returns
"*ERROR* - Could not locate key" if the specified element name sequence and instance could not be found
Usage
Use this function to extract specific attribute
values contained within
XML data
Examples
The following examples demonstrate typical syntax/usage for this function.
• ph_snapxml(ph_readfile("c:\powerhome\phdata.xml"),"row<temperature",3)
- Returns the string
of
data appearing between the 3rd instance of the opening and closing tags
of the specified key (temperature) contained in the c:\powerhome\phdata.xml file. The
search that
is performed must match the format
of <row>...<temperature>...</temperature>...</row>