Solved

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

Posted on 2004-09-16
2
3,163 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now