Summary:
See also: Built-in Classes, XML Utils
The DomDocument class provides methods to manipulate a data tree, following the DOM standards.
om.DomDocument
Class Methods | |
Name | Description |
create( tag STRING ) RETURNING om.DomDocument |
Creates a new, empty DomDocument object, where tag identifies the tag name of the root element. |
createFromXmlFile( file STRING ) RETURNING om.DomDocument |
Creates a new DomDocument object using an XML file specified by the parameter file. Returns NULL if an error occurs. |
Object Methods | |
Name | Description |
copy( src om.DomNode, deep INTEGER ) RETURNING om.DomNode |
Clones a DomNode (with child nodes if deep is TRUE). |
createChars( text STRING ) RETURNING om.DomNode |
Creates a DomNode as a text node. |
createElement( tag STRING ) RETURNING om.DomNode |
Creates a new empty DomNode object with a tag name specified by tag. |
getDocumentElement( ) RETURNING om.DomNode |
Returns the root node of the DOM document. |
getElementById( id INTEGER ) RETURNING om.DomNode |
An internal integer identifier is automatically assigned to each DomNode object. With this method, you get an element by its id. |
removeElement( e om.DomNode ) |
Removes a DomNode object and any descendent DomNodes from the document. |
A unique root DomNode object is owned by a DomDocument object.
You can get the root node with the DomDocument.getDocumentElement() method.
You can get a specific node by its internal identifier with the DomDocument.getElementById() method.
New nodes can be created with the DomDocument.createElement() method, and inserted in the DOM tree with the DomNode.insertbefore() method.
New text nodes can be created with the DomDocument.createChars() method, and inserted in the DOM tree with the DomNode.insertbefore() method.
Once you have the root element, you can recursively manipulate child nodes with the DomNode class methods.
01
MAIN02
DEFINE d om.DomDocument03
DEFINE r om.DomNode04
LET d = om.DomDocument.create("MyDocument")05
LET r = d.getDocumentElement()06
END MAIN