Chapter 46. DBMS_XMLDOM

Table of Contents

46.1. Overview
46.2. Types
46.2.1. DOMAttr
46.2.2. DOMCDataSection
46.2.3. DOMCharacterData
46.2.4. DOMComment
46.2.5. DOMDocument
46.2.6. DOMDocumentFragment
46.2.7. DOMDocumentType
46.2.8. DOMElement
46.2.9. DOMEntity
46.2.10. DOMEntityReference
46.2.11. DOMImplementation
46.2.12. DOMNamedNodeMap
46.2.13. DOMNode
46.2.14. DOMNodeList
46.2.15. DOMNotation
46.2.16. DOMProcessingInstruction
46.2.17. DOMText
46.3. Procedures and Functions
46.3.1. ADOPTNODE
46.3.2. APPENDCHILD
46.3.3. CREATECDATASECTION
46.3.4. CREATECOMMENT
46.3.5. CREATEELEMENT
46.3.6. CREATETEXTNODE
46.3.7. FREEDOCFRAG
46.3.8. FREEDOCUMENT
46.3.9. FREENODE
46.3.10. GETATTRIBUTE
46.3.11. GETATTRIBUTENODE
46.3.12. GETATTRIBUTES
46.3.13. GETCHILDNODES
46.3.14. GETCHILDRENBYTAGNAME
46.3.15. GETDOCUMENTELEMENT
46.3.16. GETELEMENTSBYTAGNAME
46.3.17. GETFIRSTCHILD
46.3.18. GETLASTCHILD
46.3.19. GETLENGTH
46.3.20. GETNAME
46.3.21. GETNAMEDITEM
46.3.22. GETNODENAME
46.3.23. GETNODETYPE
46.3.24. GETNODEVALUE
46.3.25. GETOWNERDOCUMENT
46.3.26. GETPARENTNODE
46.3.27. GETVALUE
46.3.28. GETXMLTYPE
46.3.29. HASATTRIBUTE
46.3.30. IMPORTNODE
46.3.31. INSERTBEFORE
46.3.32. ISNULL
46.3.33. ITEM
46.3.34. MAKEATTR
46.3.35. MAKEDOCUMENT
46.3.36. MAKEELEMENT
46.3.37. MAKENODE
46.3.38. NEWDOMDOCUMENT
46.3.39. REMOVEATTRIBUTE
46.3.40. REMOVECHILD
46.3.41. REPLACECHILD
46.3.42. SETATTRIBUTE
46.3.43. SETVALUE
46.3.44. WRITETOCLOB

This chapter briefly introduces the DBMS_XMLDOM package, and describes how to use the procedures and functions of the package. DBMS_XMLDOM package is not supported in AIX, Windows, Linux IA64, Solaris x86.

46.1. Overview

DBMS_XMLDOM provides DOM API for XML document processing.

This section describes the constants defined in the DBMS_XMLDOM package.

  • ELEMENT_NODE

    ELEMENT_NODE CONSTANT PLS_INTEGER := 1;
  • ATTRIBUTE_NODE

    ATTRIBUTE_NODE CONSTANT PLS_INTEGER := 2;
  • TEXT_NODE

    TEXT_NODE CONSTANT PLS_INTEGER := 3;
  • CDATA_SECTION_NODE

    CDATA_SECTION_NODE CONSTANT PLS_INTEGER := 4;
  • ENTITY_REFERENCE_NODE

    ENTITY_REFERENCE_NODE CONSTANT PLS_INTEGER := 5;
  • ENTITY_NODE

    ENTITY_NODE CONSTANT PLS_INTEGER := 6;
  • PROCESSING_INSTRUCTION_NODE

    PROCESSING_INSTRUCTION_NODE CONSTANT PLS_INTEGER := 7;
  • COMMENT_NODE

    COMMENT_NODE CONSTANT PLS_INTEGER := 8;
  • DOCUMENT_NODE

    DOCUMENT_NODE CONSTANT PLS_INTEGER := 9;
  • DOCUMENT_TYPE_NODE

    DOCUMENT_TYPE_NODE CONSTANT PLS_INTEGER := 10;
  • DOCUMENT_FRAGMENT_NODE

    DOCUMENT_FRAGMENT_NODE CONSTANT PLS_INTEGER := 11;
  • NOTATION_NODE

    NOTATION_NODE CONSTANT PLS_INTEGER := 12;

46.2. Types

This section describes the types provided by the DBMS_XMLDOM package.

46.2.1. DOMAttr

A RECORD type with a RAW type ID. Represents an attribute in the DOM object.

Details about the DOMAttr type are as follows:

  • Prototype

    TYPE DOMAttr IS RECORD(id RAW(16));

46.2.2. DOMCDataSection

A RECORD type with a RAW type ID. Represents a CDataSection object.

Details about the DOMCDataSection type are as follows:

  • Prototype

    TYPE DOMCDataSection IS RECORD(id RAW(16));

46.2.3. DOMCharacterData

A RECORD type with a RAW type ID. Represents a CharacterData object.

Details about the DOMCharacterData type are as follows:

  • Prototype

    TYPE DOMCharacterData IS RECORD(id RAW(16));

46.2.4. DOMComment

A RECORD type with a RAW type ID. Represents a Comment object.

Details about the DOMComment type are as follows:

  • Prototype

    TYPE DOMComment IS RECORD(id RAW(16));

46.2.5. DOMDocument

A RECORD type with a RAW type ID. Represents a Document object.

Details about the DOMDocument type are as follows:

  • Prototype

    TYPE DOMDocument IS RECORD(id RAW(16));

46.2.6. DOMDocumentFragment

A RECORD type with a RAW type ID. Represents a DocumentFragment object.

Details about the DOMDocumentFragment type are as follows:

  • Prototype

    TYPE DOMDocumentFragment IS RECORD(id RAW(16));

46.2.7. DOMDocumentType

A RECORD type with a RAW type ID. Represents a DocumentType object.

Details about the DOMDocumentType type are as follows:

  • Prototype

    TYPE DOMDocumentType IS RECORD(id RAW(16));

46.2.8. DOMElement

A RECORD type with a RAW type ID. Represents an element object.

Details about the DOMElement type are as follows:

  • Prototype

    TYPE DOMElement IS RECORD(id RAW(16));

46.2.9. DOMEntity

A RECORD type with a RAW type ID. Represents an Entity object.

Details about the DOMEntity type are as follows:

  • Prototype

    TYPE DOMEntity IS RECORD(id RAW(16));

46.2.10. DOMEntityReference

A RECORD type with a RAW type ID. Represents an EntityReference object.

Details about the DOMEntityReference type are as follows:

  • Prototype

    TYPE DOMEntityReference IS RECORD(id RAW(16));

46.2.11. DOMImplementation

A RECORD type with a RAW type ID. Represents an Implementation object.

Details about the DOMImplementation type are as follows:

  • Prototype

    TYPE DOMImplementation IS RECORD(id RAW(16));

46.2.12. DOMNamedNodeMap

A RECORD type with a RAW type ID. Represents a NamedNodeMap object.

Details about the DOMNamedNodeMap type are as follows:

  • Prototype

    TYPE DOMNamedNodeMap IS RECORD(id RAW(16));

46.2.13. DOMNode

A RECORD type with a RAW type ID. Represents a Node object.

Details about the DOMNode type are as follows:

  • Prototype

    TYPE DOMNode IS RECORD(id RAW(16));

46.2.14. DOMNodeList

A RECORD type with a RAW type ID. Represents a NodeList object.

Details about the DOMNodeList type are as follows:

  • Prototype

    TYPE DOMNodeList IS RECORD(id RAW(16));

46.2.15. DOMNotation

A RECORD type with a RAW type ID. Represents a Notation object.

Details about the DOMNotation type are as follows:

  • Prototype

    TYPE DOMNotation IS RECORD(id RAW(16));

46.2.16. DOMProcessingInstruction

A RECORD type with a RAW type ID. Represents a ProcessingInstruction object.

Details about the DOMProcessingInstruction type are as follows:

  • Prototype

    TYPE DOMProcessingInstruction IS RECORD(id RAW(16));

46.2.17. DOMText

A RECORD type with a RAW type ID. Represents a Text object.

Details about the DOMText type are as follows:

  • Prototype

    TYPE DOMText IS RECORD(id RAW(16));

46.3. Procedures and Functions

This section describes the procedures and functions provided by the DBMS_XMLDOM package, in alphabetical order.

46.3.1. ADOPTNODE

Adds the selected node to the Document, and deletes the node from the previous document it belonged to.

Details about the ADOPTNODE function are as follows:

  • Prototype

    DBMS_XMLDOM.ADOPTNODE
    (
        doc               IN           DOMDocument,
        importedNode      IN           DOMNode
    )
    RETURN DOMNode;
  • Parameters

    ParameterDescription
    docDocument to add the node to.
    importedNodeNode to add to the Document.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        new_doc   dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        n_ele     dbms_xmldom.DOMNode;
    begin
        doc := dbms_xmldom.newDomDocument;
        new_doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        n_ele := dbms_xmldom.makeNode(ele);
        n := dbms_xmldom.appendChild(root, n_ele);
        n := dbms_xmldom.adoptNode(new_doc, n_ele);
    end;
    /

46.3.2. APPENDCHILD

Adds a child node to the specified node and outputs the new child node.

Details about the APPENDCHILD function are as follows:

  • Prototype

    DBMS_XMLDOM.APPENDCHILD
    (
        n             IN              DOMNode,
        newchild      IN              DOMNode
    )
    RETURN DOMNode;
  • Parameters

    ParameterDescription
    nNode to add the child node to.
    newchildNew child node.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        n := dbms_xmldom.makeNode(ele);
        n := dbms_xmldom.appendChild(root, n);
    end;
    /

46.3.3. CREATECDATASECTION

Creates a CDataSection in the specified document.

Details about the CREATECDATASECTION function are as follows:

  • Parameters

    ParameterDescription
    docDocument to create a CDataSection for.
    dataContent for CDataSection.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        cd        dbms_xmldom.DOMCDataSection;
    begin
        doc := dbms_xmldom.newDomDocument;
        cd  := dbms_xmldom.createCDataSection(doc, 'contents of cdatasection');
    end;
    /

46.3.4. CREATECOMMENT

Creates a COMMENT in the specified document.

Details about the CREATECOMMENT function are as follows:

  • Prototype

    DBMS_XMLDOM.CREATECOMMENT
    (
        doc           IN              DOMDocument,
        data          IN              VARCHAR2
    )  
    RETURN DOMComment;
  • Parameters

    ParameterDescription
    docDocument to create a COMMENT for.
    dataContent for COMMENT.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        cm        dbms_xmldom.DOMComment;
    begin
        doc := dbms_xmldom.newDomDocument;
        cm  := dbms_xmldom.createComment(doc, 'comment!!');
    end;
    /

46.3.5. CREATEELEMENT

Creates an element in the specified document.

Details about the CREATEELEMENT function are as follows:

  • Prototype

    DBMS_XMLDOM.CREATEELEMENT
    (
        doc           IN              DOMDocument,
        tagname       IN              VARCHAR2
    )  
    RETURN DOMElement;
  • Parameters

    ParameterDescription
    docDocument to create an element for.
    tagnameTagname of the Element.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
    end;
    /

46.3.6. CREATETEXTNODE

Creates a Text node in the specified document.

Details about the CREATETEXTNODE function are as follows:

  • Prototype

    DBMS_XMLDOM.CREATETEXTNODE
    (
        doc           IN              DOMDocument,
        data          IN              VARCHAR2
    ) 
    RETURN DOMText;
  • Parameters

    ParameterDescription
    docDocument to create a Text node for.
    dataText content.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        txt       dbms_xmldom.DOMText;
    begin
        doc := dbms_xmldom.newDomDocument;
        txt := dbms_xmldom.createTextNode(doc, 'text');
    end;
    /

46.3.7. FREEDOCFRAG

Initializes the specified DOMDocumentFragment object.

Details about the FREEDOCFRAG procedure are as follows:

  • Prototype

    DBMS_XMLDOM.FREEDOCFRAG
    (
        doc          IN              DOMDocumentFragment
    );
  • Parameter

    ParameterDescription
    dfDocumentFragment to initialize.

46.3.8. FREEDOCUMENT

Frees resources associated with the specified Document.

Details about the FREEDOCUMENT procedure are as follows:

  • Prototype

    DBMS_XMLDOM.FREEDOCUMENT
    (
        doc          IN              DOMDocument
    );
  • Parameter

    ParameterDescription
    docDocument to free the resources for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
    begin
        doc := dbms_xmldom.newDomDocument;
        dbms_xmldom.freedocument(doc);
    end;
    /

46.3.9. FREENODE

Frees resources associated with the specified DOMNode. If the DOMNode is a document, the DOMNode object is initialized and the document and its resources are freed. Otherwise, only the DOMNode object is initialized.

Details about the FREENODE procedure are as follows:

  • Prototype

    DBMS_XMLDOM.FREENODE
    (
        n          IN              DOMNode
    );
  • Parameter

    ParameterDescription
    nNode to free resources for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
    begin
        doc := dbms_xmldom.newDomDocument;
        dbms_xmldom.freenode(dbms_xmldom.makeNode(doc));
    end;
    /

46.3.10. GETATTRIBUTE

Gets the attribute value of the specified Element.

Details about the GETATTRIBUTE function are as follows:

  • Prototype

    DBMS_XMLDOM.GETATTRIBUTE
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2
    )
    RETURN VARCHAR2;
    DBMS_XMLDOM.GETATTRIBUTE
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2,
        ns            IN              VARCHAR2
    )
    RETURN VARCHAR2;
  • Parameters

    ParameterDescription
    elemElement of the specified attribute.
    nameAttribute name.
    nsAttribute namespace.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        x         XMLType;
        attr_val  VARCHAR2;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_xmldom.setAttribute(ele, 'attr1');
        attr_val := dbms_xmldom.getAttribute(ele, 'attr1');
        dbms_output.put_line(attr_val);
    end;
    /

46.3.11. GETATTRIBUTENODE

Gets the specified DOMAttr of the Element.

Details about the GETATTRIBUTENODE function are as follows:

  • Prototypes

    DBMS_XMLDOM.GETATTRIBUTENODE
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2
    )
    RETURN DOMAttr;
    DBMS_XMLDOM.GETATTRIBUTENODE
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2,
        ns            IN              VARCHAR2
    )
    RETURN DOMAttr;
  • Parameters

    ParameterDescription
    elemElement of the attribute.
    nameAttribute name.
    nsAttribute namespace.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        attr  dbms_xmldom.DOMAttr;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_xmldom.setAttribute(ele, 'attr1');
        attr := dbms_xmldom.getAttributeNode(ele, 'attr1');
    end;
    /

46.3.12. GETATTRIBUTES

Gets all attributes of the specified Element.

Details about the GETATTRIBUTES function are as follows:

  • Prototype

    DBMS_XMLDOM.GETATTRIBUTES
    (
        n          IN              DOMNode
    )
    RETURN DOMNamedNodeMap;
  • Parameter

    ParameterDescription
    nMust be a DOMNode Element.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        attr      dbms_xmldom.DOMAttr;
        nm        dbms_xmldom.DOMNamedNodeMap;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_xmldom.setAttribute(ele, 'attr1');
        dbms_xmldom.setAttribute(ele, 'attr2');
        nm := dbms_xmldom.getAttributes(dbms_xmldom.makeNode(ele));
    end;
    /

46.3.13. GETCHILDNODES

Gets the child nodes of the specified node.

Details about the GETCHILDNODES function are as follows:

  • Prototype

    DBMS_XMLDOM.GETCHILDNODES
    (
        n          IN              DOMNode
    )
    RETURN DOMNodeList;
  • Parameter

    ParameterDescription
    nParent node to get the child nodes for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        p         dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        nl        dbms_xmldom.DOMNodeList;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        p := dbms_xmldom.appendChild(root, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child1');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child2');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child3');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        nl := dbms_xmldom.getChildNodes(p);
    end;
    /

46.3.14. GETCHILDRENBYTAGNAME

Gets the child nodes that contain elements with the specified tagname.

Details about the GETCHILDRENBYTAGNAME function are as follows:

  • Prototypes

    DBMS_XMLDOM.GETCHILDRENBYTAGNAME
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2
    )
    RETURN DOMNodeList;
    DBMS_XMLDOM.GETCHILDRENBYTAGNAME
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2,
        ns            IN              VARCHAR2
    )
    RETURN DOMNodeList;
  • Parameters

    ParameterDescription
    elemParent element node of the child nodes.
    nameTagname to search for.
    nsNamespace to search for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        p         dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        nl        dbms_xmldom.DOMNodeList;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        p := dbms_xmldom.appendChild(root, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child1');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child1');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child3');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        nl := dbms_xmldom.getChildrenByTagName(p, 'child1');
    end;
    /

46.3.15. GETDOCUMENTELEMENT

Gets the root element of the specified document.

Details about the GETDOCUMENTELEMENT function are as follows:

  • Prototype

    DBMS_XMLDOM.GETDOCUMENTELEMENT
    (
        doc          IN              DOMDocument
    )
    RETURN DOMElement;
  • Parameter

    ParameterDescription
    docDocument to get the root element for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        n := dbms_xmldom.appendChild(root, dbms_xmldom.makeNode(ele));
        n := dbms_xmldom.getDocumentElement(doc);
    end;
    /

46.3.16. GETELEMENTSBYTAGNAME

Gets the elements with the specified tagname.

Details about the GETELEMENTSBYTAGNAME function are as follows:

  • Prototypes

    DBMS_XMLDOM.GETELEMENTSBYTAGNAME
    (
        doc           IN              DOMDocument,
        name          IN              VARCHAR2
    )
    RETURN DOMNodeList;
    DBMS_XMLDOM.GETELEMENTSBYTAGNAME
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2
    )
    RETURN DOMNodeList;
    DBMS_XMLDOM.GETELEMENTSBYTAGNAME
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2,
        ns            IN              VARCHAR2
    )
    RETURN DOMNodeList;
  • Parameters

    ParameterDescription
    docDocument node to get the elements for.
    elemParent element node of the child Elements.
    nameTagname to search for.
    nsNamespace to search for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        p         dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        nl        dbms_xmldom.DOMNodeList;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        p := dbms_xmldom.appendChild(root, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child1');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child1');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child3');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        nl := dbms_xmldom.getElementsByTagname(doc, 'child1');
    end;
    /

46.3.17. GETFIRSTCHILD

Gets the first child node.

Details about the GETFIRSTCHILD function are as follows:

  • Prototype

    DBMS_XMLDOM.GETFIRSTCHILD
    (
        n           IN              DOMNode
    )
    RETURN DOMNode;
  • Parameter

    ParameterDescription
    nParent node to get the child node for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        p         dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        p := dbms_xmldom.appendChild(root, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child1');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child2');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child3');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        n := dbms_xmldom.getFirstChild(p);
    end;
    /

46.3.18. GETLASTCHILD

Gets the last child node.

Details about the GETLASTCHILD function are as follows:

  • Prototype

    DBMS_XMLDOM.GETLASTCHILD
    (
        n           IN              DOMNode
    )
    RETURN DOMNode;
  • Parameter

    ParameterDescription
    nParent node to get the child node for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        p         dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        p := dbms_xmldom.appendChild(root, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child1');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child2');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child3');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        n := dbms_xmldom.getLastChild(p);
    end;
    /

46.3.19. GETLENGTH

Gets the number of characters for CharacterData, and the number of nodes for DOMNamedNodeMap or DOMNodeList.

Details about the GETLENGTH function are as follows:

  • Prototypes

    DBMS_XMLDOM.GETLENGTH
    (
        cd           IN              DOMCharacterData
    )
    RETURN NUMBER;
    DBMS_XMLDOM.GETLENGTH
    (
        nnm           IN              DOMNamedNodeMap
    )
    RETURN NUMBER;
    DBMS_XMLDOM.GETLENGTH
    (
        nl           IN              DOMNodeList
    )
    RETURN NUMBER;
  • Parameters

    ParameterDescription
    cdNode of the CharacterData.
    nnmType that represents multiple node information in a Map.
    nlType that represents multiple node information in a List.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        p         dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        nl        dbms_xmldom.DOMNodeList;
        len       Number;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        p := dbms_xmldom.appendChild(root, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child1');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child2');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child3');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        nl := dbms_xmldom.getElementsByTagname(doc, 'child1');
        len := dbms_xmldom.getLength(nl);
    end;
    /

46.3.20. GETNAME

Gets the name of the specified node.

Details about the GETNAME function are as follows:

  • Prototypes

    DBMS_XMLDOM.GETNAME
    (
        a           IN              DOMAttr
    )
    RETURN VARCHAR2;
    DBMS_XMLDOM.GETNAME
    (
        dt           IN              DOMDocumentType
    )
    RETURN VARCHAR2;
  • Parameters

    ParameterDescription
    aAttribute node.
    dtDOMDocumentType node.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        attr  dbms_xmldom.DOMAttr;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_xmldom.setAttribute(ele, 'attr1');
        attr := dbms_xmldom.getAttributeNode(ele, 'attr1');
        dbms_output.put_line(dbms_xmldom.getName(attr));
    end;
    /

46.3.21. GETNAMEDITEM

Gets the specified node from DOMNamedNodeMap.

Details about the GETNAMEDITEM function are as follows:

  • Prototypes

    DBMS_XMLDOM.GETNAMEDITEM
    (
        nnm         IN              DOMNamedNodeMap,
        name        IN              VARCHAR2
    )
    RETURN DOMNode;
    DBMS_XMLDOM.GETNAMEDITEM
    (
        nnm         IN              DOMNamedNodeMap,
        name        IN              VARCHAR2,
        ns          IN              VARCHAR2
    )
    RETURN DOMNode;
  • Parameters

    ParameterDescription
    nnmDOMNamedNodeMap.
    nameName of the node.
    nsNamespace of the node.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        attr      dbms_xmldom.DOMAttr;
        nm        dbms_xmldom.DOMNamedNodeMap;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_xmldom.setAttribute(ele, 'attr1');
        dbms_xmldom.setAttribute(ele, 'attr2');
        nm := dbms_xmldom.getAttributes(dbms_xmldom.makeNode(ele));
        n := dbms_xmldom.getNamedItem(nm, 'attr1');
    end;
    /

46.3.22. GETNODENAME

Gets the name of the specified node.

Details about the GETNODENAME function are as follows:

  • Prototype

    DBMS_XMLDOM.GETNODENAME
    (
        n         IN              DOMNode
    )
    RETURN VARCHAR2;
  • Parameter

    ParameterDescription
    nName of the node.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        attr      dbms_xmldom.DOMAttr;
        nm        dbms_xmldom.DOMNamedNodeMap;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_xmldom.setAttribute(ele, 'attr1');
        dbms_xmldom.setAttribute(ele, 'attr2');
        nm := dbms_xmldom.getAttributes(dbms_xmldom.makeNode(ele));
        n := dbms_xmldom.getNamedItem(nm, 'attr1');
        dbms_output.put_line(dbms_xmldom.getNodeName(n));
    end;
    /

46.3.23. GETNODETYPE

Gets the DBMS_XMLDOM constant that represents the node type.

Details about the GETNODETYPE function are as follows:

  • Prototype

    DBMS_XMLDOM.GETNODETYPE
    (
        n         IN              DOMNode
    )
    RETURN NUMBER;
  • Parameter

    ParameterDescription
    nNode to get the type information for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_output.put_line(dbms_xmldom.getNodeType(dbms_xmldom.makeNode(doc)));
        dbms_output.put_line(dbms_xmldom.getNodeType(dbms_xmldom.makeNode(ele)));
    end;
    /

46.3.24. GETNODEVALUE

Gets the value of the specified node.

Details about the GETNODEVALUE function are as follows:

  • Prototype

    DBMS_XMLDOM.GETNODEVALUE
    (
        n         IN              DOMNode
    )
    RETURN VARCHAR2;
  • Parameter

    ParameterDescription
    nNode to get the value for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_output.put_line(dbms_xmldom.getNodeValue(dbms_xmldom.makeNode(ele)));
    end;
    /

46.3.25. GETOWNERDOCUMENT

Gets the document of the specified node.

Details about the GETOWNERDOCUMENT function are as follows:

  • Prototype

    DBMS_XMLDOM.GETOWNERDOCUMENT
    (
        n         IN              DOMNode
    )
    RETURN DOMDocument;
  • Parameter

    ParameterDescription
    nNode to get the document for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        doc := dbms_xmldom.getOwnerDocument(dbms_xmldom.makeNode(ele));
    end;
    /

46.3.26. GETPARENTNODE

Gets the parent node of the specified node.

Details about the GETPARENTNODE function are as follows:

  • Prototype

    DBMS_XMLDOM.GETPARENTNODE
    (
        n           IN              DOMNode
    )
    RETURN DOMNode;
  • Parameter

    ParameterDescription
    nNode to get the parent for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        p         dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        n1         dbms_xmldom.DOMNode;
        n2         dbms_xmldom.DOMNode;
        n3         dbms_xmldom.DOMNode;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        p := dbms_xmldom.appendChild(root, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child1');
        n1 := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child2');
        n2 := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child3');
        n3 := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        n := dbms_xmldom.getParentNode(n1);
    end;
    /

46.3.27. GETVALUE

Gets the value of the specified attribute node.

Details about the GETVALUE function are as follows:

  • Prototype

    DBMS_XMLDOM.GETVALUE
    (
        a         IN              DOMAttr
    )
    RETURN VARCHAR2;
  • Parameter

    ParameterDescription
    aAttribute node to get the value for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        attr      dbms_xmldom.DOMAttr;
        attr_val  VARCHAR2;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_xmldom.setAttribute(ele, 'attr1');
        attr := dbms_xmldom.getAttributeNode(ele, 'attr1');
        attr_val := dbms_xmldom.getVal(attr);
        dbms_output.put_line(attr_val);
    end;
    /

46.3.28. GETXMLTYPE

Gets the XMLType of the Document.

Details about the GETXMLTYPE function are as follows:

  • Prototype

    DBMS_XMLDOM.GETXMLTYPE
    (
        doc          IN              DOMDocument
    )
    RETURN XMLType;
  • Parameter

    ParameterDescription
    docDOM document to get the XMLTYPE for.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        x         XMLType;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        n := dbms_xmldom.makeNode(ele);
        n := dbms_xmldom.appendChild(root, n);
        x := dbms_xmldom.getXMLType(doc);
    end;
    /

46.3.29. HASATTRIBUTE

Checks if the specified element node has a specific ATTRIBUTE.

Details about the HASATTRIBUTE function are as follows:

  • Prototypes

    DBMS_XMLDOM.HASATTRIBUTE
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.HASATTRIBUTE
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2,
        ns            IN              VARCHAR2
    )
    RETURN BOOLEAN;
  • Parameters

    ParameterDescription
    elemElement to find the attribute in.
    nameAttribute name.
    nsAttribute namespace.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        x         XMLType;
        has_attr  BOOLEAN;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_xmldom.setAttribute(ele, 'attr1');
        has_attr := dbms_xmldom.HasAttribute(ele, 'attr1');
    end;
    /

46.3.30. IMPORTNODE

Imports a node from another document and returns it as a new node.

Details about the IMPORTNODE function are as follows:

  • Prototype

    DBMS_XMLDOM.IMPORTNODE
    (
        doc               IN              DOMDocument,
        importedNode      IN              DOMNode,
        deep              IN              BOOLEAN
    )
    RETURN DOMNode;
  • Parameters

    ParameterDescription
    docDocument from which to import the node from.
    importedNodeNode to import.
    deep
    • True: Also import the entire subtree of the node with the node.

    • False: Only import the node itself.

  • Example

    declare
        doc1       dbms_xmldom.DOMDocument;
        doc2       dbms_xmldom.DOMDocument;
        ele1       dbms_xmldom.DOMElement;
        ele2       dbms_xmldom.DOMElement;
        root       dbms_xmldom.DOMNode;
        n0         dbms_xmldom.DOMNode;
        n1         dbms_xmldom.DOMNode;
        n2         dbms_xmldom.DOMNode;
    begin
        doc1 := dbms_xmldom.newDomDocument;
        doc2 := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc1);
        ele1 := dbms_xmldom.createElement(doc1, 'root');
        ele2 := dbms_xmldom.createElement(doc1, 'ele');
        n1 := dbms_xmldom.appendChild(root, dbms_xmldom.makeNode(ele1));
        n2 := dbms_xmldom.appendChild(n1, dbms_xmldom.makeNode(ele2));
        n0 := dbms_xmldom.importNode(doc2, n1, FALSE);
    end;
    /

46.3.31. INSERTBEFORE

Imports a node before the specified node. If the specified node is Null, inserts the node at the end of all child nodes.

Details about the INSERTBEFORE function are as follows:

  • Prototype

    DBMS_XMLDOM.INSERTBEFORE
    (
        n             IN              DOMNode,
        newchild      IN              DOMNode,
        refchild      IN              DOMNode
    )
    RETURN DOMNode;
  • Parameters

    ParameterDescription
    nParent node of the refchild node.
    newchildChild to insert.
    refchildnewchild node is inserted before the refchild node.
  • Example

    declare
        doc        dbms_xmldom.DOMDocument;
        ele        dbms_xmldom.DOMElement;
        ele1       dbms_xmldom.DOMElement;
        ele2       dbms_xmldom.DOMElement;
        ele3       dbms_xmldom.DOMElement;
        root       dbms_xmldom.DOMNode;
        nele       dbms_xmldom.DOMNode;
        n          dbms_xmldom.DOMNode;
        n1         dbms_xmldom.DOMNode;
        n2         dbms_xmldom.DOMNode;
    begin
        doc  := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele  := dbms_xmldom.createElement(doc, 'root');
        ele1 := dbms_xmldom.createElement(doc, 'ele1');
        ele2 := dbms_xmldom.createElement(doc, 'ele2');
        ele3 := dbms_xmldom.createElement(doc, 'ele3');
        nele := dbms_xmldom.appendChild(root, dbms_xmldom.makeNode(ele));
        n1   := dbms_xmldom.appendChild(nele, dbms_xmldom.makeNode(ele1));
        n2   := dbms_xmldom.appendChild(nele, dbms_xmldom.makeNode(ele2));
        n := dbms_xmldom.insertBefore(nele, dbms_xmldom.makeNode(ele3), n1);
    end;
    /

46.3.32. ISNULL

Checks if the specified object is NULL.

Details about the ISNULL function are as follows:

  • Prototypes

    DBMS_XMLDOM.ISNULL
    (
        a             IN              DOMAttr
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        cds           IN              DOMCDataSection
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        cd            IN              DOMCharacterData
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        com           IN              DOMComment
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        doc           IN              DOMDocument
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        df            IN              DOMDocumentFragment
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        dt            IN              DOMDocumentType
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        elem          IN              DOMElement
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        ent           IN              DOMEntity
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        eref          IN              DOMEntityReference
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        di            IN              DOMImplementation
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        nnm           IN              DOMNamedNodeMap
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        n             IN              DOMNode
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        nl            IN              DOMNodeList
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        n             IN              DOMNotation
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        pi            IN              DOMProcessingInstruction
    )
    RETURN BOOLEAN;
    DBMS_XMLDOM.ISNULL
    (
        t             IN              DOMText
    )
    RETURN BOOLEAN;
  • Example

    declare
        doc        dbms_xmldom.DOMDocument;
    begin
        dbms_xmldom.isNULL(doc);
        doc  := dbms_xmldom.newDomDocument;
        dbms_xmldom.isNULL(doc);   
    end;
    /

46.3.33. ITEM

Gets the item in the NamedNodeMap or NodeList.

Details about the ITEM function are as follows:

  • Prototypes

    DBMS_XMLDOM.ITEM
    (
        nl         IN              DOMNodeList,
        index      IN              Number
    )
    RETURN DOMNode;
    DBMS_XMLDOM.ITEM
    (
        nnm        IN              DOMNamedNodeMap,
        index      IN              Number
    )
    RETURN DOMNode;
  • Parameters

    ParameterDescription
    nlNodeList of the item.
    nnmNamedNodeMap of the item.
    indexIndex of the item.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        p         dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        nl        dbms_xmldom.DOMNodeList;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        p := dbms_xmldom.appendChild(root, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child1');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child2');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        ele := dbms_xmldom.createElement(doc, 'child3');
        n := dbms_xmldom.appendChild(p, dbms_xmldom.makeNode(ele));
        nl := dbms_xmldom.getChildNodes(p);
        n := dbms_xmldom.item(nl, 1);
    end;
    /

46.3.34. MAKEATTR

Casts the specified node to an attribute.

Details about the MAKEATTR function are as follows:

  • Prototype

    DBMS_XMLDOM.MAKEATTR
    (
        n            IN              DOMNode
    )
    RETURN DOMAttr;
  • Parameter

    ParameterDescription
    nDOMNode to cast to DOMAttr.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        attr      dbms_xmldom.DOMAttr;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_xmldom.setAttribute(ele, 'attr1');
        attr := dbms_xmldom.getAttributeNode(ele, 'attr1');
        n := dbms_xmldom.makeNode(attr);
        attr := dbms_xmldom.makeAttr(n);
    end;
    /

46.3.35. MAKEDOCUMENT

Casts the specified node to a Document.

Details about the MAKEDOCUMENT function are as follows:

  • Prototype

    DBMS_XMLDOM.MAKEDOCUMENT
    (
        n            IN              DOMNode
    )
    RETURN DOMDocument;
  • Parameter

    ParameterDescription
    nDOMNode to cast to DOMDocument.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        root      dbms_xmldom.DOMNode;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        doc := dbms_xmldom.makeAttr(root);
    end;
    /

46.3.36. MAKEELEMENT

Casts the specified node to an Element.

Details about the MAKEELEMENT function are as follows:

  • Prototype

    DBMS_XMLDOM.MAKEELEMENT
    (
        n            IN              DOMNode
    )
    RETURN DOMElement;
  • Parameter

    ParameterDescription
    nDOMNode to cast to DOMElement.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        n         dbms_xmldom.DOMNode;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        n := dbms_xmldom.makeNode(ele);
        ele := dbms_xmldom.makeElement(n);
    end;
    /

46.3.37. MAKENODE

Casts the specified document to a node.

Details about the MAKENODE function are as follows:

  • Prototype

    DBMS_XMLDOM.MAKENODE
    (
        doc          IN              DOMDocument
    )
    RETURN DOMNode;
  • Parameter

    ParameterDescription
    docDOMDocument to cast to DOMNode.
  • Example

    declare
        doc          dbms_xmldom.DOMDocument;
        root         dbms_xmldom.DOMNode;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
    end;
    /

46.3.38. NEWDOMDOCUMENT

Creates a DOM type document.

Details about the NEWDOMDOCUMENT function are as follows:

  • Prototype

    DBMS_XMLDOM.NEWDOMDOCUMENT
    RETURN DOMDocument;
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
    begin
        doc := dbms_xmldom.newDomDocument;
    end;
    /

46.3.39. REMOVEATTRIBUTE

Removes the specified attribute from the element node.

Details about the REMOVEATTRIBUTE procedure are as follows:

  • Prototypes

    DBMS_XMLDOM.REMOVEATTRIBUTE
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2
    );
    DBMS_XMLDOM.REMOVEATTRIBUTE
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2,
        ns            IN              VARCHAR2
    );
  • Parameters

    ParameterDescription
    elemElement of the attribute.
    nameAttribute name.
    nsAttribute namespace.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        x         XMLType;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_xmldom.setAttribute(ele, 'attr1');
        has_attr := dbms_xmldom.removeAttribute(ele, 'attr1');
    end;
    /

46.3.40. REMOVECHILD

Removes the specified child node of the node.

Details about the REMOVECHILD function are as follows:

  • Prototype

    DBMS_XMLDOM.REMOVECHILD
    (
        n             IN              DOMNode,
        oldchild      IN              DOMNode
    )
    RETURN DOMNode;
  • Parameters

    ParameterDescription
    nParent node of the child node.
    oldchildChild node to remove.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        nele      dbms_xmldom.DOMNode;
        deleted   dbms_xmldom.DOMNode;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        nele := dbms_xmldom.makeNode(ele);
        nele := dbms_xmldom.appendChild(root, nele)
        deleted := dbms_xmldom.removeChild(root, nele);
    end;
    /

46.3.41. REPLACECHILD

Replaces the specified child node of the node.

Details about the REPLACECHILD function are as follows:

  • Prototype

    DBMS_XMLDOM.REPLACECHILD
    (
        n             IN              DOMNode,
        newchild      IN              DOMNode,
        oldchild      IN              DOMNode
    )
    RETURN DOMNode;
  • Parameters

    ParameterDescription
    nParent node of the child node.
    newchildNew child node.
    oldchildOld child node.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele1      dbms_xmldom.DOMElement;
        ele2      dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        nele1     dbms_xmldom.DOMNode;
        nele2     dbms_xmldom.DOMNode;
        replaced  dbms_xmldom.DOMNode;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele1 := dbms_xmldom.createElement(doc, 'root');
        ele2 := dbms_xmldom.createElement(doc, 'newroot');
        nele1 := dbms_xmldom.makeNode(ele1);
        nele2 := dbms_xmldom.makeNode(ele2);
        nele1 := dbms_xmldom.appendChild(root, nele1)
        replaced := dbms_xmldom.replaceChild(root, nele2, nele1);
    end;
    /

46.3.42. SETATTRIBUTE

Adds a new attribute to the specified element.

Details about the SETATTRIBUTE procedure are as follows:

  • Prototypes

    DBMS_XMLDOM.SETATTRIBUTE
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2,
        newvalue      IN              VARCHAR2
    );
    DBMS_XMLDOM.SETATTRIBUTE
    (
        elem          IN              DOMElement,
        name          IN              VARCHAR2,
        newvalue      IN              VARCHAR2,
        ns            IN              VARCHAR2
    );
  • Parameters

    ParameterDescription
    elemElement.
    nameAttribute name.
    newvalueAttribute value.
    nsAttribute namespace.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        x         XMLType;
        attr_val  VARCHAR2;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_xmldom.setAttribute(ele, 'attr1');
        attr_val := dbms_xmldom.getAttribute(ele, 'attr1');
        dbms_output.put_line(attr_val);
    end;
    /

46.3.43. SETVALUE

Sets the value of the specified attribute node.

Details about the SETVALUE procedure are as follows:

  • Prototype

    DBMS_XMLDOM.SETVALUE
    (
        a         IN              DOMAttr,
        value     IN              VARCHAR2
    );
  • Parameter

    ParameterDescription
    aAttribute node.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        attr      dbms_xmldom.DOMAttr;
    begin
        doc := dbms_xmldom.newDomDocument;
        ele := dbms_xmldom.createElement(doc, 'root');
        dbms_xmldom.setAttribute(ele, 'attr1');
        attr := dbms_xmldom.getAttributeNode(ele, 'attr1');
        dbms_xmldom.setVal(attr, 'new_attr');
    end;
    /

46.3.44. WRITETOCLOB

Writes DOM document to the specified CLOB.

Details about the WRITETOCLOB procedure are as follows:

  • Prototype

    DBMS_XMLDOM.WRITETOCLOB
    (
        doc          IN              DOMDocument,
        cl           OUT             CLOB
    );
  • Parameters

    ParameterDescription
    docDOM type document.
    clCLOB to write to.
  • Example

    declare
        doc       dbms_xmldom.DOMDocument;
        ele       dbms_xmldom.DOMElement;
        root      dbms_xmldom.DOMNode;
        n         dbms_xmldom.DOMNode;
        cl        CLOB;
    begin
        doc := dbms_xmldom.newDomDocument;
        root := dbms_xmldom.makeNode(doc);
        ele := dbms_xmldom.createElement(doc, 'root');
        n := dbms_xmldom.makeNode(ele);
        n := dbms_xmldom.appendChild(root, n);
        dbms_xmldom.writeToClob(doc, cl);
    end;
    /