XMLElement With Use of Namespaces
SELECT
 XMLElement("Tax", 
  XMLAttributes('http://www.w3.org/2001/XMLSchema'
                AS  "xmlns:xsi",
                'http://www.kayshav.com/Tax.xsd'
                AS  "xsi:nonamespaceSchemaLocation"),
  XMLForest(loc_id, city, tax)
  ) AS  XML_out
FROM
 (SELECT 101 loc_id, 'New York' city, 5600 tax FROM DUAL UNION
  SELECT 102 loc_id, 'San Jose' city, 5900 tax FROM DUAL UNION
  SELECT 103 loc_id, 'Houston'  city, 3750 tax FROM DUAL)
WHERE loc_id <= 102;
Reference Output of Above Query
XMLElement With use of Namespaces

-- Note: CAST function to be used to get XML content in 
-- SQL Developer

Actual Output

Oracle registered trademark of Oracle Corporation.

Last Revised On: October 20, 2013

  69968