Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-09-16
2
Medium Priority
?
3,446 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 1600 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

971 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