Home > Class Reference > %SYS namespace > %XML.Node

%XML.Node

class %XML.Node extends %Library.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 Inventory

    Method Inventory

    Properties

    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 methods: DocumentGet(), DocumentGetSwizzled(), DocumentIsValid(), DocumentNewObject(), DocumentSet()
    property LocalName as %String [ Calculated ];
    Local name for element node.
    Property methods: LocalNameDisplayToLogical(), LocalNameGet(), LocalNameIsValid(), LocalNameLogicalToDisplay(), LocalNameLogicalToOdbc(), LocalNameNormalize(), LocalNameSet()
    property Namespace as %String [ Calculated ];
    XML namespace for element node.
    Property methods: NamespaceDisplayToLogical(), NamespaceGet(), NamespaceIndexDisplayToLogical(), NamespaceIndexGet(), NamespaceIndexIsValid(), NamespaceIndexLogicalToDisplay(), NamespaceIndexLogicalToOdbc(), NamespaceIndexNormalize(), NamespaceIndexSet(), NamespaceIsValid(), NamespaceLogicalToDisplay(), NamespaceLogicalToOdbc(), NamespaceNormalize(), NamespaceSet()
    property NamespaceIndex as %String [ Calculated ];
    Index into XML namespace table for element node.
    Property methods: NamespaceIndexDisplayToLogical(), NamespaceIndexGet(), NamespaceIndexIsValid(), NamespaceIndexLogicalToDisplay(), NamespaceIndexLogicalToOdbc(), NamespaceIndexNormalize(), NamespaceIndexSet()
    property Nil as %Boolean [ Calculated ];
    True if xsi:nil or xsi:null specified as true or 1 for this element node.
    Property methods: NilDisplayToLogical(), NilGet(), NilIsValid(), NilLogicalToDisplay(), NilNormalize(), NilSet()
    property NodeData as %String [ Calculated ];
    Value of a character node.
    Property methods: NodeDataDisplayToLogical(), NodeDataGet(), NodeDataIsValid(), NodeDataLogicalToDisplay(), NodeDataLogicalToOdbc(), NodeDataNormalize(), NodeDataSet()
    property NodeId as %String;
    The id of the current node. The NodeId property may be set in order to move the specified node.
    Property methods: NodeIdDisplayToLogical(), NodeIdGet(), NodeIdIsValid(), NodeIdLogicalToDisplay(), NodeIdLogicalToOdbc(), NodeIdNormalize(), NodeIdSet()
    property NodeType as %String [ Calculated ];
    Type of node: $$$xmlELEMENTNODE, $$$xmlTEXTNODE, $$$xmlWHITESPACENODE.
    Property methods: NodeTypeDisplayToLogical(), NodeTypeGet(), NodeTypeIsValid(), NodeTypeLogicalToDisplay(), NodeTypeLogicalToOdbc(), NodeTypeNormalize(), NodeTypeSet()
    property QName as %String [ Calculated ];
    Qname for element node. Only used for output as XML when the prefix is valid for the document.
    Property methods: QNameDisplayToLogical(), QNameGet(), QNameIsValid(), QNameLogicalToDisplay(), QNameLogicalToOdbc(), QNameNormalize(), QNameSet()

    Methods

    method AppendCharacter(text As %String, raw As %Boolean, parent As %String) [ Language = objectscript ]
    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.
    If raw is true, the node is marked as $$$xmlRAWTEXTNODE
    parent is for internal use only.
    method AppendElement(localName As %String, namespace As %String = "", text As %String, qname As %String = "") [ Language = objectscript ]
    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 AppendNode(sourceNode As %XML.Node) as %Status [ Language = objectscript ]
    Append a copy of the specified node to the list of children of this node. The node to copy may be from any document. The current node pointer does not change. This node is still the parent of the appended child.
    method AppendTree(sourceNode As %XML.Node) as %Status [ Language = objectscript ]
    Append a copy of the specified node, including all its children, to the list of children of this node. The tree to copy may be from any document, but this node may not be a descendant of the source node. The current node pointer does not change. This node is still the parent of the appended child.
    method AttributeDefined(attributeName As %String) as %String [ Language = objectscript ]
    Return non-zero (true) if attribute named attributeName exists for this element.
    method FirstAttributeName() as %String [ Language = objectscript ]
    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) [ Language = objectscript ]
    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) [ Language = objectscript ]
    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 [ Language = objectscript ]
    Return namespace URI from QName of attribute named attributeName for this element.
    method GetAttributeQName(attributeName As %String) as %String [ Language = objectscript ]
    Return QName of attribute named attributeName for this element.
    method GetAttributeQNameNS(attributeName As %String, namespace As %String) as %String [ Language = objectscript ]
    Return QName of attribute named attributeName in namespace for this element.
    method GetAttributeValue(attributeName As %String) as %String [ Language = objectscript ]
    Return value of attribute named attributeName for this element.
    method GetAttributeValueNS(attributeName As %String, namespace As %String) as %String [ Language = objectscript ]
    Return value of attribute named attributeName in namespace for this element.
    method GetAttributeValueNamespace(attributeName As %String) as %String [ Language = objectscript ]
    Return namespace of value of attribute named attributeName for this element.
    method GetAttributeValueNamespaceNS(attributeName As %String, namespace As %String) as %String [ Language = objectscript ]
    Return namespace value of attribute named attributeName in namespace for this element.
    method GetNumberAttributes() as %Integer [ Language = objectscript ]
    Return number of attributes for this element.
    method GetText(ByRef text, mixed As %Boolean = 0) as %Boolean [ Language = objectscript ]
    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 [ Language = objectscript ]
    Return non-zero (true) if this node has any child nodes.
    method InsertCharacter(text As %String, ByRef child As %String) as %String [ Language = objectscript ]
    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 child node is specified by passing its NodeId. The child node is passed by reference so that it may be updated with a new NodeId after the insert. 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 InsertElement(localName As %String, namespace As %String = "", ByRef child As %String, text As %String, qname As %String = "") as %String [ Language = objectscript ]
    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 child node is specified by passing its NodeId. The child node is passed by reference so that it may be updated with a new NodeId after the insert. 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 InsertNode(sourceNode As %XML.Node, ByRef child As %String, Output sc As %Status) as %String [ Language = objectscript ]
    Insert a copy of the specified node to the list of children of this node. The node to copy may be from any document. The new node is inserted just before the specified child node. The child node is specified by passing its NodeId. The child node is passed by reference so that it may be updated with a new NodeId after the insert. The nodeId of the inserted node is returned. The current node pointer does not change.
    method InsertTree(sourceNode As %XML.Node, ByRef child As %String, Output sc As %Status) as %String [ Language = objectscript ]
    Insert a copy of the specified node, including its children, to the list of children of this node. The tree to copy may be from any document, but this node may not be a descendant of the source node. The new node is inserted just before the specified child node. The child node is specified by passing its NodeId. The child node is passed by reference so that it may be updated with a new NodeId after the insert. The nodeId of the inserted node is returned. The current node pointer does not change.
    method IsDescendant(sourceNode As %XML.Node) as %Boolean [ Language = objectscript ]
    Check is a this node is the descendant of specified node
    method LastAttributeName() as %String [ Language = objectscript ]
    Return attribute name for last attribute for this element.
    method MoveToFirstChild(skipWhitespace As %Boolean = 0) as %Boolean [ Language = objectscript ]
    Move node to current node's first child node. Optionally skip whitespace nodes.
    method MoveToLastChild(skipWhitespace As %Boolean = 0) as %Boolean [ Language = objectscript ]
    Move node to current node's last child node. Optionally skip whitespace nodes.
    method MoveToNextSibling(skipWhitespace As %Boolean = 0) as %Boolean [ Language = objectscript ]
    Move node to current node's next sibling. Optionally skip whitespace nodes.
    method MoveToParent(restrictDocumentNode As %Boolean = 0) as %Boolean [ Language = objectscript ]
    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 [ Language = objectscript ]
    Move node to current node's ancestor which has the specified local name.
    method MoveToPreviousSibling(skipWhitespace As %Boolean = 0) as %Boolean [ Language = objectscript ]
    Move node to current node's previous sibling. Optionally skip whitespace nodes.
    method NextAttributeName(attributeName As %String) as %String [ Language = objectscript ]
    Return attribute name for next attribute for this element.
    method PreviousAttributeName(attributeName As %String) as %String [ Language = objectscript ]
    Return attribute name for previous attribute for this element.
    method Remove() [ Language = objectscript ]
    Remove the current node and make its parent the current node.
    method RemoveAttribute(attributeName As %String) [ Language = objectscript ]
    Remove attribute named attributeName for this element.
    method RemoveAttributeNS(attributeName As %String, namespace As %String) [ Language = objectscript ]
    Remove attribute named attributeName in namespace for this element.
    method ReplaceCharacter(text As %String) [ Language = objectscript ]
    Replace this node with a character node.
    method ReplaceElement(localName As %String, namespace As %String = "", text As %String, qname As %String = "") [ Language = objectscript ]
    Replace this node with an element node.
    method ReplaceNode(sourceNode As %XML.Node) as %Status [ Language = objectscript ]
    Replace this node with a copy of the specified node. The node to copy may be from any document. The current node pointer does not change.
    method ReplaceTree(sourceNode As %XML.Node) as %Status [ Language = objectscript ]
    Replace this node with a copy of the specified node including all its children. The tree to copy may be from any document, but this node may not be a descendant of the source node. The current node pointer does not change.
    method Serialize(Output endElementText) as %String [ Language = objectscript ]
    Serialize this node as element
    method SetAttribute(attributeName As %String, namespace As %String = "", value As %String = "", valueNamespace As %String = "") [ Language = objectscript ]
    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".
  • Inherited Members

    Inherited Methods

    Subclasses