Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Oracle DBMS_XMLQUERY - Remove <?xml version = '1.0'?> Tag

Posted on 2004-09-16
2
3,221 Views
Last Modified: 2008-01-09
I am using the DBMS_XMLQUERY package to generate some XML from a query.  I am interested in turning off the <?xml version = '1.0'?> header tag that is returned with the XML document.  I attempted the following unsuccessfully:

DBMS_XMLQUERY.setencodingtag (v_xml_query, '')

The document still comes back with the <?xml version = '1.0'?> header tag.

Can anyone tell me how to turn this off?

Thanks.
0
Comment
Question by:L1Alpha01
2 Comments
 
LVL 7

Accepted Solution

by:
grim_toaster earned 400 total points
ID: 12081941
Using DBMS_XMLQUERY.setencodingtag (v_xml_query, '') will only clear out the encoding part of the header text, which would be the "encoding = 'UTF-8'" part in the example below:
<?xml version = '1.0' encoding = 'UTF-8'?>

There is no way to not generate this, all you can do is manipulate the returned CLOB to remove the tag, for example:

CREATE OR REPLACE FUNCTION get_xml(queryStr VARCHAR2) RETURN CLOB AS
    v_ctx_handle DBMS_XMLQUERY.ctxType;
      v_results CLOB;
      v_instr INTEGER;
BEGIN
       v_ctx_handle := DBMS_XMLQUERY.newContext(queryStr);
       v_results := DBMS_XMLQUERY.getXML(v_ctx_handle);
       DBMS_XMLQUERY.closeContext(v_ctx_handle);

       v_instr := INSTR(v_results, '<ROWSET>') - 1;
       IF (v_instr > 0) THEN
             DBMS_LOB.ERASE(v_results, v_instr);
       END IF;
       RETURN v_results;
END;
0
 

Author Comment

by:L1Alpha01
ID: 12227354
I'm sorry for not following up sooner...I got wrapped up in another project and completely forgot about the question I posted.  I've increased the point level 100 points (from 300 to 400) for my oversight.

Thanks  
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question