GetXml() method in DataSet -- Problem

R

Rajesh AVRS

Hi guys

I have a requirement where I needed to extract the DataSet contents as
XML.

After filling the dataset, I am calling GetXml() and is working fine.

However, one of the column which I am querying, is CLOB data in XML
format.

Let us say, my dataSet looks like this after the select query:

COLUMN_A COLUMN_B
1 <A>AAA</A>

I expected the GetXml() method to return me the following:

<Table>
<COLUMN_A>1</COLUMN_A>
<COLUMN_B><A>AAA</A></COLUMN_B>
</Table>

But what I was this:

<Table>
<COLUMN_A>1</COLUMN_A>
<COLUMN_B>&lt;A&gt;AAA&lt;/A&gt;</COLUMN_B>
</Table>

Basically the GetXml() method is treating the XML in Column B as text
which I don't want.

I want the GetXml() to treat the Column B value as subnode in the
returned xml.

Is there anyway to do this?

Appreciate your help.

thanks,
Rajesh
 
G

Guest

I've just spent the last 10 minutes use Reflector to look through the
different methods on a DataSet for saving it to XML. From what I can see the
GetXml call calls the internal class XmlDataTreeWriter which in turn calls
XmlDataRowWriter for each DataRow in the dataset which eventually calls
WriteString of an XmlWriter passing in the result of ConvertObjectToXml of
what is presumably the StringStorage class.... which returns the exact string
as it is in the database.

However, ..... and on we go. Suffice to say, the string is encoding along
the way. I can't see a way, other then to write your own encoder to get
around the problem of GetXml encoding it.

However, if you do have a deterministic way of knowing where in the
resultant string representing the XML that the encoded values appear, you
could create an XmlDocument from it, go to that string and then call
HttpUtility.HtmlDecode on the contents.

Sorry I couldn't be of more help.

Brian Delahunty
Ireland
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top