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

%XML.Document

class %XML.Document extends %XML.ImportHandler, %XML.Node

%XML.Document represents an XML document as an Document Object Model (DOM). The DOM 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.Document class maintains the namespaces for the DOM. The %XML.Node class created by GetDocumentElement() may be used to navigate the DOM or the macros in %xmlDOM.inc may be used to navigate the DOM based on the DocumentId of %XML.Document.

    Method Inventory

    Methods

    method CountNamespace() as %Integer
    Return number of namepsaces in document's namespace table.
    classmethod CreateDocument(localName As %String, namespace As %String) as %XML.Document
    Create a new Document Object Model (DOM) consisting of only a root element.
    method FindNamespace(namespace As %String) as %Integer
    Return XML nsIndex into document's namespace table for namespace URI.
    method GetDocumentElement() as %XML.Node
    Returns an %XML.Node DOM navigation object which is positioned at the the root element of this Document.
    classmethod GetDocumentFromStream(stream As %BinaryStream, Output document As %XML.Document) as %Status
    Create a doocument by parsing the XML document contained in a stream.
    The parsed document is returned in document.
    A %Status is returned to indicate if parsing is successful.
    method GetDocumentNode() as %String
    Returns the node id of the root element of this Document.
    method GetNamespace(nsIndex As %Integer) as %String
    Return XML namespace URI for nsIndex into document's namespace table.
    method GetNode(nodeId As %String) as %XML.Node
    Returns an %XML.Node DOM navigation object which is positioned at the the node specified by the nodeId argument.
    method GetNodeById(id As %String)
    Return nodeId for node with id attribute = %id.
    method GetVersion() as %Integer
    Return the version of the import handler that constructed this document. A programmatically constructed DOM will always have version "".
    method InsertNamespace(namespace As %String)
    Return XML namespace URI for nsIndex into document's namespace table.
    method SetNodeById(id As %String, nodeId As %Integer)
    Save nodeId for node with id attribute = %id.

    Inherited Methods