GetXMLNodeArray

(System Library)

Description:

Searches the result returned from XMLParse and returns an array of XMLNode values of a given type. Returns Invalid if no matches are found.

Returns: Array of XMLNodes.
Usage: Script Only.
Function Groups: XML
Related to: XMLProcessor | XMLAddSchema | XMLWrite | XMLCloneNode | XMLCreateNode | XMLDeleteMember | XMLGetNode | XMLParse
Format: System.GetXMLNodeArray(XMLContainer, ElementType)
Parameters:  
XMLContainer
The XMLNode within which to search for element type name. Only the direct child nodes of this node are searched.
This is the equivalent of the first parameter of the Scope operator.
ElementType
The element type name to search for.
This is equivalent to the second parameter of the Scope operator.
Comments:

This helper function was created to work with the results of XMLParse.

GetXMLNodeArray searches the immediate children of a given XMLNode value (first parameter) for elements with the type name provided by the second parameter and returns those elements in an array of XMLNodes. This serves to simplify parsing of XMLNode trees, which may contain lists of repeating elements.

Elements in the returned array will be in the same order as in they were in the original XML document.

If no elements with the given name are found, then this function will return INVALID.

Examples:

  Source = "<X><Y>"Hello"</Y><Y>" "</Y><Y>"world"</Y><Y>"!"</Y></X>";  
  XMLProc = XMLProcessor(INVALID);
  XMLParse(XMLProc, Source, Errors, Document);
  RootNode = XMLGetNode(Scope(Document, "X"));
  TextNodes = System.GetXMLNodeArray(RootNode, "Y");

At this point TextNodes will contain an array of four XMLNodes, containing "Hello", " ", "world", and "!" respectively.