NEWDOMDOCUMENT v18

The NEWDOMDOCUMENT function accepts XMLTYPE or CLOB as input and returns the DOMDocument type. It can also create an empty DOMDocument.

NEWDOMDOCUMENT RETURN DOMDocument

NEWDOMDOCUMENT(xmldoc IN XMLTYPE) RETURN DOMDocument;

NEWDOMDOCUMENT (cl IN CLOB) RETURN DOMDocument;

Parameters

xmldoc

The XMLTYPE of source for the DOMDocument.

cl

The CLOB source for the DOMDocument.

Example

This example creates an XML DOMDocument, sets the version to 1.0, and converts it to an XMLType object.

DECLARE
   l_xmltype XMLTYPE;
   l_domdoc DBMS_XMLDOM.DOMDocument;


BEGIN
   l_domdoc := DBMS_XMLDOM.NEWDOMDOCUMENT();
   DBMS_XMLDOM.SETVERSION(l_domdoc, '1.0');
   l_xmltype := DBMS_XMLDOM.GETXMLTYPE(l_domdoc);
   DBMS_OUTPUT.PUT_LINE(l_xmltype.getStringVal());
END;

This example takes an XMLType object, converts it to a DOMDocument, and then converts it back to XMLType.

DECLARE
   doc DBMS_XMLDOM.DOMDocument;
   xmldata xmltype:=xmltype('<r><a>10</a><b><bb>20</bb></b></r>');
   l_xmltype XMLTYPE;
BEGIN
   doc := DBMS_XMLDOM.NEWDOMDOCUMENT(xmldata);
   l_xmltype := DBMS_XMLDOM.GETXMLTYPE(doc);
   DBMS_OUTPUT.PUT_LINE(l_xmltype::varchar2);


END;