XMLGetNode

(Engine-Level Function)

Description: Returns an XMLNode from a tree.
Returns: The XMLNode specified.
Usage: Script Only.
Function Groups: XML
Related to: XMLParse | XMLProcessor | XMLAddSchema | XMLWrite | XMLCloneNode | XMLCreateNode | XMLDeleteMember | GetXMLNodeArray
Format: XMLGetNode(XMLNode)
Parameters:  
XMLNode
Required. The XMLNode to return.
Comments: When isolating a particular XMLNode, to pass to a subroutine for instance, the automatic subscripting of an XMLNode to provide the value in its #content member means that this is passed to the subroutine.
Thus,
   GoodXML = Valid(XMLGetNode(XMLData));

Is not equivalent to

   XMLObject = XMLGetNode(XMLData);
   GoodXML  = Valid(XMLObject);

To defeat the automatic subscripting, use this function.

See notes in VTScada Engine XML API for a discussion of how to address arrays within an XML node.

Example:

Given an XMLNode named "MyNode" as created with the following code:

AttribsDict = Dictionary(0);
AttribsDict["id"] = 42;
MembersDict = Dictionary(0);
MembersDict["Item1"] = XMLCreateNode("01234567890");
MyNode = XMLCreateNode("abc", AttribsDict, 
                       "http://trihedral.com/XML", MembersDict);

Then calling a subroutine as follows will pass the value of the #content member to the subroutine, in this case: "abc":

MySub(MyNode);

To pass the actual node use the following construct:

MySub(XMLGetNode(MyNode));

Note that a similar construct uses the address-of operator (&) but then the subroutine will have to de-reference the parameter (using the * operator) on every use.