xml.DomDocument methods

Methods for the xml.DomDocument class.

Table 1. Class methods: Creation
Name Description
xml.DomDocument.create()
  RETURNS xml.DomDocument
Constructor of an empty DomDocument object.
xml.DomDocument.createDocument(
   name STRING )
  RETURNS xml.DomDocument
Constructor of a DomDocument with a XML root element.
xml.DomDocument.createDocumentNS(
   prefix STRING,
   name STRING,
   ns STRING )
  RETURNS xml.DomDocument
Constructor of a DomDocument with a root namespace-qualified XML root element
Table 2. Object methods: Navigation
Name Description
getDocumentElement()
  RETURNS xml.DomNode
Returns the root XML Element DomNode object for this DomDocument object.
getDocumentNodesCount()
  RETURNS INTEGER
Returns the number of child DomNode objects for a DomDocument object.
getDocumentNodeItem(
   index INTEGER )
  RETURNS xml.DomNode
Returns the child DomNode object at a given position for this DomDocument object.
getElementById(
   id STRING )
  RETURNS xml.DomNode
Returns the element that has an attribute of type ID with the given value.
getElementsByTagName(
   tag STRING )
  RETURNS xml.DomNodeList
Returns a DomNodeList object containing all XML Element DomNode objects with the same tag name in the entire document.
getElementsByTagNameNS(
   tag STRING,
   ns STRING )
  RETURNS xml.DomNodeList
Returns a DomNodeList object containing all namespace qualified XML Element DomNode objects with the same tag name and namespace in the entire document
getFirstDocumentNode()
  RETURNS xml.DomNode
Returns the first child DomNode object for a DomDocument object.
getLastDocumentNode()
  RETURNS xml.DomNode
Returns the last child DomNode object in a DomDocument object.
selectByXPath(
   expr STRING,
   args ... )
  RETURNS xml.DomNodeList
Returns a DomNodeList object containing all DomNode objects matching a XPath 1.0 expression.
Table 3. Object methods: Management
Name Description
appendDocumentNode(
   n xml.DomNode )
Adds a child DomNode object to the end of the DomNode children for this DomDocument object.
clone()
  RETURNS xml.DomDocument
Returns a copy of a DomDocument object.
declareNamespace(
   node xml.DomNode,
   alias STRING,
   ns STRING )
Forces namespace declaration to a XML Element DomNode for a DomDocument object.
insertAfterDocumentNode(
   newNode xml.DomNode,
   ref xml.DomNode )
Inserts a child DomNode object after another child DomNode in a DomDocument object.
insertBeforeDocumentNode(
   newNode xml.DomNode,
   ref xml.DomNode )
Inserts a child DomNode object before another child DomNode for this DomDocument object.
importNode(
   n xml.DomNode
   deep INTEGER )
  RETURNS xml.DomNode
Imports a DomNode from a DomDocument object into its new context (attached to a DomDocument object).
prependDocumentNode(
   n xml.DomNode )
Adds a child DomNode object to the beginning of the DomNode children of a DomDocument object
removeDocumentNode(
   n xml.DomNode )
Removes a child DomNode object from the DomNode children in a DomDocument object.
Table 4. Object methods: Node Creation
Name Description
createAttribute(
   elt STRING )  
  RETURNS xml.DomNode
Creates a XML Attribute DomNode object for a DomDocument object.
createAttributeNS(
   prefix STRING,
   elt STRING,
   ns STRING )
  RETURNS xml.DomNode
Creates a XML namespace-qualified Attribute DomNode object for a DomDocument object.
createCDATASection(
   data STRING )  
  RETURNS xml.DomNode
Creates an XML CData DomNode object for a DomDocument object.
createComment(
   cmt STRING )  
  RETURNS xml.DomNode
Creates a XML Comment DomNode object for a DomDocument object.
createDocumentFragment()
  RETURNS xml.DomNode
Creates a XML Document Fragment DomNode object for a DomDocument object.
createDocumentType(
   name STRING,
   publicID STRING,
   systemID STRING,
   internalSubset STRING )  
  RETURNS xml.DomNode
Creates a XML Document Type (DTD) DomNode object for a DomDocument object.
createElement(
   elt STRING ) 
  RETURNS xml.DomNode
Creates a XML Element DomNode object for a DomDocument object
createElementNS(
   prefix STRING,
   elt STRING,
   ns STRING )
  RETURNS xml.DomNode
Creates a XML namespace-qualified Element DomNode object for a DomDocument object.
createEntityReference(
   entity STRING )  
  RETURNS xml.DomNode
Creates a XML EntityReference DomNode object for a DomDocument object
createNode(
   str STRING ) 
  RETURNS xml.DomNode
Creates a XML DomNode object from a string for a DomDocument object.
createProcessingInstruction(
   target STRING,
   data STRING )
  RETURNS xml.DomNode
Creates a XML Processing Instruction DomNode object for this DomDocument object.
createTextNode(
   txt STRING )  
  RETURNS xml.DomNode
Creates a XML Text DomNode object for a DomDocument object.
Table 5. Object methods: Load and Save
Name Description
load(
   filename STRING )
Loads a XML Document into a DomDocument object from a file or an URL.
loadFromPipe(
   name STRING )
Loads a XML Document into a DomDocument object from a PIPE.
loadFromString(
   xmlstr STRING )
Loads a XML Document into a DomDocument object from a string.
normalize()
Normalizes the entire Document.
save(
   filename STRING )
Saves a DomDocument object as a XML Document to a file or URL.
saveToPipe(
   name STRING )
Saves a DomDocument object as an XML Document to a PIPE.
saveToString() 
  RETURNS STRING
Saves a DomDocument object as a XML Document to a string.
Table 6. Object methods: Configuration
Name Description
getFeature(
   property STRING)
  RETURNS STRING
Gets a feature for a DomDocument object.
getXmlEncoding()
  RETURNS STRING
Returns the document encoding as defined in the XML document declaration.
getXmlVersion()
  RETURNS STRING
Returns the document version as defined in the XML document declaration.
isXmlStandalone()
  RETURNS INTEGER
Checks whether the XML standalone attribute is set in the XML declaration.
setFeature(
   property STRING,
   value STRING)
Sets a feature for a DomDocument object.
setXmlEncoding(
   encoding STRING )
Sets the XML document encoding in the XML declaration.
setXmlStandalone(
   alone INTEGER )
Sets the XML standalone attribute in the XML declaration to "yes" or "no" in the XML declaration, or removes the standalone attribute.
Table 7. Object methods: Validation
Name Description
validate( )
  RETURNS INTEGER
Performs a DTD or XML Schema validation for a DomDocument object.
validateOneElement(
   elt xml.DomNode )
  RETURNS INTEGER
Performs a DTD or XML Schema validation of a XML Element DomNode object.
Table 8. Object methods: Error Management
Name Description
getErrorsCount()
  RETURNS INTEGER
Returns the number of errors encountered during the loading, saving or validation of a XML document.
getErrorDescription(
   index INTEGER )
  RETURNS STRING
Returns the error description at the given position.