Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
update set column values in oracle 3 42
oracle query help 18 74
Oracle Database Upgrade 13 40
statspack purge automate 7 27
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…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

771 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

11 Experts available now in Live!

Get 1:1 Help Now