Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle XML problem - difference in 9i and 10g

Re: Oracle XML problem - difference in 9i and 10g

From: Vladimir M. Zakharychev <>
Date: 15 Sep 2006 11:18:40 -0700
Message-ID: <> wrote:
> [test case skipped...]
> It appears that the Processing instructions are no longer counted. Ive
> tried this on Windows 9i, Linux 9i, Windows 10g and Linux 10g databases
> and the results are consistant - which would lead me to belive that it
> was an intentional change. If this is so, how would i go about
> extracting all the PI's from the document if its not possible to use
> the wildcard in getElementsByTagName()? I cant use the XMLTYPE as I
> need to update the docuement and from what i can see thats not possible
> unless i load into the dom using dbms_xmldom.
> Any help would be extremly appreciated!
> Neil

Well, according to the DOM specification, ProcessingInstruction is not an Element, thus it should not be returned by getElementsByTagName(). So 10g behavior seems to be correct. In fact, in 9i I get the same results as in 10g (no PI's.) To extract all PI's from the document, you need to use getChildNodes() recursively until hasChildNodes() returns false, and loop through child nodes looking for PI's. I see no other way getting them all with DOM but traversing the whole document tree.

More efficient could be writing a Java stored procedure using SAX parser - since you are only interested in PI's, you only need to implement processingInstruction() in the handler, which will put each PI into a Vector or whatever you will find suitable. Besides, since SAX is event-driven, memory requirements are pretty low regardless the size of the document, unlike DOM, which needs to instantiate the whole document in memory before you can do anything with it. Oracle provides its own SAX parser implementation: oracle.xml.parser.v2.SAXParser.


    Vladimir M. Zakharychev
    N-Networks, makers of Dynamic PSP(tm) Received on Fri Sep 15 2006 - 13:18:40 CDT

Original text of this message