VTScada Engine XML API

Applications created prior to VTS 10 that used XML must be re-coded to be compatible with changes made to the API in that release.

If your goal is only to read data from an external XML source, use the JSON driver tag rather than writing code.

The XML API is used to create an XML Processor, which is a script code interface to allow an XML document to be represented in a manner that is easy for a script to access and manipulate. An XML Processor serves as a conduit between an XML document and an application that will do something with the content found in that document.

How to Access an Array Within an XML Node:

The XML code always tries to drill down into the #content member when scoping, so that retrieving the actual content of a node is a simple scope operation.

When there are multiple XML nodes with the same name, they are held as an array and can be accessed via the subscript operator []. The result will be the #content member of the XMLNode you have subscripted. To get a specific node use XMLGetNode(Node[x]) to "defeat" the automatic scoping into the #content member.

To determine if an item is an XMLNode or an array of nodes use ValueType(*XMLNode). For example, ValueType(*SomeArrayNode) returns #VTypeXMLNode (51) as it is an XMLNode, but ValueType(*NonArrayNode) does not. Note that you must use the "*" dereference operator to dereference the pointer that holds the array or XMLNode. Check only for #VTypeXMLNode because, if it is not an XMLNode, then the type could vary.

To determine how many nodes are in the array use ArraySize() on the result of an XMLGetNode call that does not include a subscript operator: ArraySize(XMLGetNode(XMLNode));