xml.DomDocument methods

Methods for the xml.DomDocument class.

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