Traditionally Xml parsing was doing using dom objects in Pl/Sql level. This method of parsing XMLs has significant performance hit, even if we left out the many loops that we have to go through to get a value of a single XML element. Enough of Dom, Lest see abut XMLtype.
Oracle 9i and above has this new type of object which is capable of recognizing a XML document end to end.
This is the link to the document. http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96620/xdb04cre.htm
And if u don’t have time to read it your self I have red it and these are some available functions to extract values safely from a XML. And all the code you see is PLSQL
1. XML is represented as CLOB.
Take the below XML as an example. The xml need (well there might be other ways too) to be provided as clob to the XML type constructor.
l_clob CLOB := '
Don’t Write Blog Posts at work
Please do not do any thing other than work while you are at work
’;2. Lest Start the fire.
Creating XML object.
xml_object:=sys.xmltype.createXML(l_clob);3.Accessing a value of a XML element. If you do this in the proper safe way this is actually three steps. Here are the steps. Check if the Item that you are trying to access exits.
Check if the value on the item is not Null.
Access the value.
IF ( xml_object.existsNode('/ROOT_TAG/HOTLINE') = 1 ) THEN IF( xml_object.extract('/ROOT_TAG/HOTLINE/text()') IS NOT NULL ) THEN xml_data_str := xml_object.extract('/ROOT_TAG/HOTLINE/text()').getStringval(); END IF;
END IF; The xml_object.existsNode just checks whether the element specified in the Xpath exists. If so returns...