Writing DataSets to XML

  • Thread starter Thread starter danpowley
  • Start date Start date
D

danpowley

Hello

I have a DataTable where one of the columns contains XML, when I add it
to a DataSet and call WriteXML it automaticaly encodes the XML ( e.g.
< becomes &lt; ) is there an easy way to prevent this encoding from
happening?

Currently I am having to parse the resultant XML and swap the encoded
values for the original XML. This works ok and produces valid XML but
I'm sure its not the best way to do it.

Thanks for any ideas
All the best
Dan
Manchester Uni. UK
 
If you use .NET 2.0 there is a XML-DataType that you can use as data type
for the column
 
Hi Dan,

you could try to create a XmlDocument from the string containing the
XML-source

XmlDocument Document = new XmlDocument();
Dokument.LoadXml(SourceString);

Then you could use XmlDocument.AppendChild at the appropriate Node.
I'll see if I can create a little sample for that. I'm not quite sure
if that's what you wanted.

Take care and have a nice weekend

Andreas
 
Thanks, this is similar to how I have worked around this issue, using
AppendChild sounds like it may be more elegant, I used
GetElementsByTagName then looped through NodeLists checking Name
properties and updating the appropriate InnerXML properties, this is
due to my ignorance of the XMLDocument object and being in a rush.

I was hoping that there would be a setting which prevented the need for
parsing an XMLDocument but it looks I'll wait until we start using .Net
2.0

Thanks very much for your help

All the best
Dan
 
Back
Top