Parsing error in pl/sql from xml created in .net

Posted on 2010-01-08
Last Modified: 2013-12-18
Hi all!

   I'm creating a pretty basic XML file in .NET and inserting it into a CLOB field in an Oracle DB - then am using a stored procedure to parse the XML and read it's contents.  I keep getting the foloowing errors:

ORA-31011: XML parsing failed
0RA-19202: Error occurred in XML processing
LPX-00217: Invalid character 0 (U+0000)

If I edit the CLOB (using a pl/sql developers tool) and delete a character and then replace the same character (doesn't matter which character I edit) - then it parses just fine.

If there are NULL characters in the CLOB - how do I remove them?

Please help!

Here's the XML that's created in the .NET app:

<?xml version="1.0" encoding="UTF-8"?>

<PARAMS type="Chart">

<CHART num="1" typeid="103" name="ATTRIBUTE_SUM" display="ATTRIBUTE SUMMARY">






Here's the way it's inserted into the DB:

while (oReader.Peek() >= 0)


    char[] sChunk = new char[1000];

    oReader.Read(sChunk, 0, sChunk.Length);

    string sContentChunk = "";

    for (int nCount = 0; nCount <= sChunk.Length - 1; nCount++)


       if (sChunk[nCount] != null)

       sContentChunk = sContentChunk + sChunk[nCount];


    if (sContentChunk.Length > 0)



          OracleType.Int32).Value = RptId;


          OracleType.VarChar).Value = sContentChunk;


           OracleType.Int32).Value = sContentChunk.Length;


           OracleType.VarChar).Value = TableName;     






Open in new window

Question by:trebems
    LVL 76

    Accepted Solution

    Even though this link is for Java I think it's the same issue.

    The ending string terminator:

    Any specific reason you're using a character array instead of a string?

    Author Comment

    I don't know why a character array was being used - I inheirited this code :)  But I changed it over to 'chunk' through a string instead - and it seems to be working.  I'll keep testing with larger XML's.

    LVL 76

    Expert Comment

    by:slightwv (䄆 Netminder)
    I guess I should have looked a little harder. The parameter being passed to Oracle was a string: sContentChunk not sChunk.

    I think the final read "oReader.Read(sChunk, 0, sChunk.Length);" was picking up the ending terminator and adding it. You might be able to leave the code as-was and just trim off the last character (if it is a '\0').

    Author Comment

    I have it working now chunking through the string - so, I think I will leave well enough alone - thanks again!

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
    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 explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
    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.

    733 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

    25 Experts available now in Live!

    Get 1:1 Help Now