XMLParse (Read and Parse an XML File)

The XMLParse function is used to read and parse an XML file in the datalogger.

Syntax

XMLParse ( XMLContent, XMLValue, AttrName, AttrNameSpace, ElemName, ElemNameSpace, MaxDepth, MaxNameSpaces )

Remarks

This function returns one of the following:

Code Description
-3 Too many name space declarations encountered while parsing element.
-2 Too many nested XML elements encountered.
-1 XML syntax error.
0 Unrecognized error condition.
1 Start of XML element. The name of the element is given in ElemName and its namespace URI is given in ElemNameSpace.
2 XML attribute read. The name of the attribute is given in AttrName and its namespace URI is given in AttrNameSpace. The value of the attribute is given in XMLValue.
3 End of XML element. The content of the element, if any, is given in XMLValue. The name and the namespace URI of the element is given, respectively, in ElemName and ElemNameSpace.
4 End of the XML document encountered. The document has been successfully parsed. Passing "Finished" into the xml_element_namespace will terminate the parsing sequence and return this code.
-4 An attempt to allocate temporary memory to hold strings larger than 64 characters has failed. "Out of memory" will also appear in the compile results.

Parameters

XMLContent (XML Content)

The XMLContent parameter is the XML content to be parsed. It can represent either a file name (using the format DeviceName:FileName) or it can represent a null terminated string that contains the XML content to be parsed.

Type: String variable or file name

XMLValue (XML Attribute Value)

The XMLValue parameter returns the value of an XML attribute when a response code of 2 is returned or it can return the value of the element content (otherwise known as its CDATA) when a result of 3 is returned.

Type: Variable

AttrName (Name of XML Attribute)

The AttrName parameter returns the name of an XML attribute when a result of 2 is returned.

Type: Variable

AttrNameSpace (Namespace URI of XML Attribute)

The AttrNameSpace parameter returns the namespace URI of an XML attribute when a result of 2 is returned.

Type: Variable

ElemName (XML Element Name)

The ElemName parameter returns the name of an XML element when a result of 2, 3, or 4 is returned.

Type: Variable

ElemNameSpace (Namespace URI of XML Element)

The ElemNameSpace parameter returns the namespace URI of an XML element when a result of 2, 3, or 4 is returned.

Type: Variable

MaxDepth (Max Nesting Depth)

The MaxDepth parameter controls, in part, the amount of memory that will be allocated for the parser. This value must be at least one greater than the anticipated maximum nesting depth of XML elements. For example, the CSIXML format, which has a maximum nesting depth of 4 elements, would require a minimum of 5 for this value. If too small of a value is specified, the parser may return a value of -2 while parsing the document.

Type: Constant

MaxNameSpaces (Maximum Number of Namespaces)

The MaxNameSpaces parameter controls, in part, the amount of memory that will be allocated for the parser. This value must be greater than equal to one or the maximum number of namespaces that are anticipated to be in the document. For instance any document that is exchanged using the SOAP protocol will likely have at least two namespaces. If too small a value is specified, the parser will return a value of -3 while parsing the document.

Type: Constant