Solved

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

Posted on 2004-09-16
2
3,312 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
[X]
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
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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
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 information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Suggested Courses

623 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