Oracle XMLComment
SELECT  XMLComment('This is an XML comment') AS xml_comment
FROM DUAL;

Oracle XMLComment Function Output
Oracle XMLPI SQL Function to Process Instructions (PI)
SELECT
 XMLPI(NAME "CURD", 'Create, Update, Read, Delete') AS xml_pi
FROM DUAL;

XMLPI Function Output
Oracle XMLRoot
SELECT  XMLRoot(XMLType('www.oratnt.com'),
    VERSION '1.0', STANDALONE YES) AS xmlroot
FROM DUAL;

Oracle XMLRoot(XMLType(..)) Function Output
Oracle XMLParse(CONTENT '..' WELLFORMED)
SELECT XMLParse(CONTENT 
  '<Tax xmlns:xsi="http://www.w3.org/2001/XMLSchema"
    xsi:nonamespaceSchemaLocation="http://www.kayshav.com/Tax.xsd">
   <LOC_ID>102</LOC_ID>
   <CITY>San Jose</CITY>
   <TAX>5900</TAX>
  </Tax>'    WELLFORMED) AS parsed_xml_data 
FROM DUAL d;

Oracle XMLParse(CONTENT '..' WELLFORMED) Function Output
Oracle XMLQuery('(...)' RETURNING CONTENT)
SELECT
 CAST(XMLQuery('(
  <type>Function</type>,
  <type>Procedure</type>,
  <type>Package</type>)' RETURNING CONTENT) 
 AS VARCHAR2(65)) AS xml_out
FROM DUAL;

Oracle XMLQuery('' RETURNING CONTENT) Function Output
Oracle XMLElement(XMLAttributes(), XMLColAttVal())

SELECT XMLElement("Emp", 
        XMLAttributes(qt.city),
        XMLColAttVal(qt.emp_id, qt.salary))
  AS xml_out 
FROM
 (SELECT 101 emp_id, 'New York' city, 5600 salary FROM DUAL UNION
  SELECT 102 emp_id, 'San Jose' city, 5900 salary FROM DUAL UNION
  SELECT 103 emp_id, 'San Jose' city, 6700 salary FROM DUAL UNION
  SELECT 104 emp_id, 'Houston'  city, 3750 salary FROM DUAL) qt
WHERE qt.emp_id >= 102;

Oracle XMLElement(XMLAttributes(), XMLColAttVal()) Function Output
Oracle XMLElement(XMLCData())

SELECT XMLElement("The White House",
         XMLElement("Address",
           XMLCDATA('1600 Pennsylvania Ave.'),
             XMLElement("City", 'Washington, D.C.')))
AS RESULT FROM DUAL;

Oracle Oracle XMLElement(XMLCData()) Function Output

Oracle XMLSerialize()
SELECT
  XMLSerialize(DOCUMENT 
     XMLType('<url>www.oratnt.com</url>') AS CLOB)
  AS xmlserialize_doc
FROM DUAL;

Oracle XMLSerialize(DOCUMENT ) Function Output

Other Oracle XML SQL Functions
XMLElement
XMLForest
XMLConcat
XMLSequence
XMLTransform
XMLAgg


Oracle registered trademark of Oracle Corporation.

Last Revised On: August 29, 2014

  1316