3 Replies Latest reply on Jun 26, 2012 8:36 AM by odie_63

    how to extract xml comments


      I have loaded XML files into my table of XML Type . I have comments in XML file. This comments are important to us and I want to extract this comments . How can we extract the comments present in XML file. I was not able to find any function which can do it.

        • 1. Re: how to extract xml comments
          Hi Ramesh,

          First of all, instead of posting three times in different forums, why not provide relevant details such as database version and a sample XML?

          Generally, XML comments are not meant to be extracted.
          If they contain so important data then most likely that data should be stored in regular element or attribute nodes.

          Here's an example using XQuery though :
          SQL> create table tmp_xml of xmltype;
          Table created
          SQL> insert into tmp_xml values (
            2   xmltype('<root>
            3  <!-- this is a comment -->
            4  <item/>
            5  <!-- this is another comment -->
            6  </root>')
            7  );
          1 row inserted
          SQL> select x.comment_text
            2  from tmp_xml t
            3     , xmltable(
            4         '/descendant::comment()'
            5         passing t.object_value
            6         columns comment_text varchar2(200) path '.'
            7       ) x
            8  ;
           this is a comment
           this is another comment
          • 2. Re: how to extract xml comments

            Thanks for the reply. It solved my issue.

            Wondering, I want not able to find information about this in any document at all.

            Thanks and Regards,
            • 3. Re: how to extract xml comments
              That's XQuery/XPath 2.0 language, you should be able to find some general tutorials on the Internet.

              Oracle implementation of it is described in the documentation :