class %XML.Node
extends %RegisteredObject
%XML.Node may be used to navigate the an XML document which is
represented as an Document Object Model (DOM) using the %XML.Document.
The %XML.Document may be created either
from an XML document by accessing the Document property of %XML.Reader
after calling an Openxxx method of %XML.Reader.
as a new DOM by calling the CreateDocument of this class.
The
%XML.Node instance that is used to navigate the DOM is created
using the
GetDocumentElement of
%XML.Document.
%XML.Node navigates through the nodes of the DOM rather
than representing a fixed node in a DOM tree. The MoveToxxx methods are used to move
through the DOM. The properties and methods of
%XML.Node are then used
to retrieve and modify the node contents.
property Document
as %XML.Document;
The DOM that this %XML.Node instance is navigating. The Document property may be
set to change which DOM is being navigated. When the Document is set, %XML.Node is
positioned at the document node, i.e. the parent of the root element.
property LocalName
as %String [ Calculated ];
Local name for element node.
property Namespace
as %String [ Calculated ];
XML namespace for element node.
property NamespaceIndex
as %String [ Calculated ];
Index into XML namespace table for element node.
property Nil
as %Boolean [ Calculated ];
True if xsi:nil or xsi:null specified as true or 1 for this element node.
property NodeData
as %String [ Calculated ];
Value of a character node.
property NodeId
as %String;
The id of the current node.
The NodeId property may be set in order to move the specified node.
property NodeType
as %String [ Calculated ];
Type of node: $$$xmlELEMENTNODE, $$$xmlTEXTNODE, $$$xmlWHITESPACENODE.
property QName
as %String [ Calculated ];
Qname for element node.
Only used for output as XML when the prefix is valid for the document.
method AppendCharacter(text As %String)
Append new character data node to the list of children of this element node.
The current node pointer does not change. This node is still the parent of the appended child.
method AppendChild(type As %Integer)
Append new node to the list of children of this node.
The current node pointer does not change. This node is still the parent of the appended child.
method AppendElement(localName As %String, namespace As %String, text As %String)
Append new element node to the list of children of this node.
If the text argument is specified, then character data is added as
the child of the new element.
The current node pointer does not change. This node is still the parent of the appended child.
method AttributeDefined(attributeName As %String)
as %String
Return non-zero (true) if attribute named attributeName exists for this element.
method FirstAttributeName()
Return attribute name for first attribute for this element.
method GetAttribute(attributeName As %String, ByRef namespace As %String, ByRef value As %String, ByRef valueNamespace As %String)
Return attribute data of attribute named attributeName for this element.
namespace is the namespace URI from QName of attribute named attributeName for this element.
value is the attribute value.
valueNamespace is the namespace URI corresponding to the prefix when the attribute value is of the form "prefix:value".
method GetAttributeNS(attributeName As %String, namespace As %String, ByRef value As %String, ByRef valueNamespace As %String)
Return attribute data of attribute named attributeName in namespace for this element.
value is the attribute value.
valueNamespace is the namespace URI corresponding to the prefix when the attribute value is of the form "prefix:value".
method GetAttributeNamespace(attributeName As %String)
as %String
Return namespace URI from QName of attribute named attributeName for this element.
method GetAttributeQName(attributeName As %String)
as %String
Return QName of attribute named attributeName for this element.
method GetAttributeQNameNS(attributeName As %String, namespace As %String)
as %String
Return QName of attribute named attributeName in namespace for this element.
method GetAttributeValue(attributeName As %String)
as %String
Return value of attribute named attributeName for this element.
method GetAttributeValueNS(attributeName As %String, namespace As %String)
as %String
Return value of attribute named attributeName in namespace for this element.
method GetAttributeValueNamespace(attributeName As %String)
as %String
Return namespace of value of attribute named attributeName for this element.
method GetAttributeValueNamespaceNS(attributeName As %String, namespace As %String)
as %String
Return namespace value of attribute named attributeName in namespace for this element.
method GetNumberAttributes()
as %Integer
Return number of attributes for this element.
method GetText(ByRef text, mixed As %Boolean = 0)
as %Boolean
Get the text contents of an element node.
GetText returns false if an error is encountered in evaluating the node.
GetText returns true if text is found. The text which is found may be the empty string.
The found text is appended to the text argument.
The text argument is created if it is not already defined.
If the mixed argument is = 1, then the mixed character and element content in the
current node is returned in the text argument.
method HasChildNodes(skipWhitespace As %Boolean = 0)
as %Boolean
Return non-zero (true) if this node has any child nodes.
method InsertCharacter(text As %String, child As %Integer)
Insert a new character data node to the list of children of this element node.
The new character data is inserted just before the specified child node.
The nodeId of the inserted character data node is returned.
The current node pointer does not change. This node is still the parent of the appended child.
method InsertChild(type As %String, child As %Integer)
as %Integer
Insert a new node to the list of children of this node.
The new node is inserted just before the specified child node.
The nodeId of the inserted node is returned.
The current node pointer does not change. This node is still the parent of the appended child.
method InsertElement(localName As %String, namespace As %String, child As %Integer, text As %String)
Insert a new element node to the list of children of this node.
The new element is inserted just before the specified child node.
The nodeId of the inserted element is returned.
If the text argument is specified, then character data is added as
the child of the new element.
The current node pointer does not change. This node is still the parent of the appended child.
method LastAttributeName()
Return attribute name for last attribute for this element.
method MoveToFirstChild(skipWhitespace As %Boolean = 0)
as %Boolean
Move node to current node's first child node.
Optionally skip whitespace nodes.
method MoveToLastChild(skipWhitespace As %Boolean = 0)
as %Boolean
Move node to current node's last child node.
Optionally skip whitespace nodes.
method MoveToNextSibling(skipWhitespace As %Boolean = 0)
as %Boolean
Move node to current node's next sibling.
Optionally skip whitespace nodes.
method MoveToParent(restrictDocumentNode As %Boolean = 0)
as %Boolean
Move node to current node's parent.
If restrictDocumentNode is true, then MoveTopParent will not move to document node.
method MoveToParentElement(localName As %String)
as %Boolean
Move node to current node's ancestor which has the specified local name.
method MoveToPreviousSibling(skipWhitespace As %Boolean = 0)
as %Boolean
Move node to current node's previous sibling.
Optionally skip whitespace nodes.
method NextAttributeName(attributeName As %String)
Return attribute name for next attribute for this element.
method PreviousAttributeName(attributeName As %String)
Return attribute name for previous attribute for this element.
method Remove()
Remove the current node and make its parent the current node.
method RemoveAttribute(attributeName As %String)
Remove attribute named attributeName for this element.
method RemoveAttributeNS(attributeName As %String, namespace As %String)
Remove attribute named attributeName in namespace for this element.
method ReplaceCharacter(text As %String)
Replace this node with a character node.
method ReplaceElement(localName As %String, namespace As %String, text As %String)
Replace this node with an element node.
method ReplaceNode(type As %Integer)
Replace this node with a specified type of node.
method Serialize(Output endElementText)
as %String
Serialize this node as element
method SetAttribute(attributeName As %String, namespace As %String = "", value As %String = "", valueNamespace As %String = "")
Set attribute data of attribute named attributeName for this element.
namespace is the namespace URI from QName of attribute named attributeName for this element.
value is the attribute value.
valueNamespace is the namespace URI corresponding to the prefix when the attribute value is of the form "prefix:value".