• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1329
  • Last Modified:

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

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!

Thanks!
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">
<CLTID>496</CLTID>
<qct_id>2404</qct_id>
<tier5_yn>N</tier5_yn>
</CHART>
</PARAMS>

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)
    {
       oraCommand.Parameters.Add("P_id",  
          OracleType.Int32).Value = RptId;
       oraCommand.Parameters.Add("P_buffer",
          OracleType.VarChar).Value = sContentChunk;
       oraCommand.Parameters.Add("P_buffer_length",
           OracleType.Int32).Value = sContentChunk.Length;
       oraCommand.Parameters.Add("p_table_name",
           OracleType.VarChar).Value = TableName;     
    }
    oraCommand.ExecuteNonQuery();
    oraCommand.Parameters.Clear();
   }
 }

Open in new window

0
trebems
Asked:
trebems
  • 2
  • 2
1 Solution
 
slightwv (䄆 Netminder) Commented:
Even though this link is for Java I think it's the same issue.

The ending string terminator:
http://forums.oracle.com/forums/thread.jspa?threadID=477449


Any specific reason you're using a character array instead of a string?
0
 
trebemsAuthor Commented:
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.

Thanks!
0
 
slightwv (䄆 Netminder) Commented:
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').
0
 
trebemsAuthor Commented:
I have it working now chunking through the string - so, I think I will leave well enough alone - thanks again!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now