473,326 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Retreiving Xml child nodes using DataSet and XmlDataDocument

I am loading an Xml file from a sql server. I have one field that
contains child nodes stored as text. The problem is, when I try to imort
the dataset into a XmlDataDocument, it loads the whole thing as a text
element. (with all of the special characters converted) The best
solution I've found so far is to do a string replace on all of the
special characters. Like so:

DataSet ds = new DataSet();
ds.EnforceConstraints = false;
SqlDataAdapter da = new SqlDataAdapter(query, connStr);
da.Fill(ds, "Keywords");
XmlDataDocument xmlDoc = new XmlDataDocument(ds);
string s = xmlDoc.SelectSingleNode("NewDataSet/Keywords/Entry").InnerText;
s = UnConvertEntities(s);
xmlDoc.SelectSingleNode("NewDataSet/Keywords/Entry").InnerXml = s;

// UnConvertEntities(string s)
s.Trim();
s.Replace("&", "&");
s.Replace("&lt;", "<");
s.Replace("&gt;", ">");
s.Replace("&apos;", "'");
s.Replace("&quot;", "\"");
return s;

Is there any better way to do this, or am I stuck with this method?
Also, I've found that this method adds a large amount of whitespace at
the end of the last element, but that may be a seperate problem.

Nov 12 '05 #1
2 5466
Anas M. Nebuchadnezzar XXXVII wrote:
I am loading an Xml file from a sql server. I have one field that
contains child nodes stored as text. The problem is, when I try to imort
the dataset into a XmlDataDocument, it loads the whole thing as a text
element.

I don't see any problem here. If it is stored as text, why it should be
not text node? Escaped markup is always a trouble waiting to happen,
always avoid it.
--
Oleg Tkachenko
XmlInsider
http://blog.tkachenko.com
Nov 12 '05 #2
Oleg Tkachenko wrote:
Anas M. Nebuchadnezzar XXXVII wrote:
I am loading an Xml file from a sql server. I have one field that
contains child nodes stored as text. The problem is, when I try to
imort the dataset into a XmlDataDocument, it loads the whole thing as
a text element.


I don't see any problem here. If it is stored as text, why it should be
not text node? Escaped markup is always a trouble waiting to happen,
always avoid it.


My problem is, It's not stored in the database escaped. I'm storing it
in a char field for lack of knowing which type works better. I've stored
the literal characters (ie. '<') and keep getting the escaped characters
(ie. '&lt;') I was wondering if there was a better way to store this
data, and convert it from text, to part of the document.

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kevin_Eld | last post by:
I have the following xml: <message> <envelope> <body key="" value="" /> </envelope> </message> I have associated an xsd to this xml in order to use the XmlDataDocument and give me the
3
by: Tom Vukovich | last post by:
and returning the xml to the requesting web page, how do you insert the XML declaration? ds.EnforceConstraints = False Response.ContentType = "text/xml" ds.WriteXml(Response.OutputStream,...
1
by: Jim Bancroft | last post by:
Hi, I'm porting a VB 6 app to .Net, and wanted to use an XMLDataDocument to store information that had previously been kept in XML Recordsets. Unfortunately, I'm not too familiar yet with...
1
by: Geoffrey Gallaway | last post by:
Hello, I'm trying to apply an XSL to a dataset contents. More specifically, I want to apply an XSL to a dataset or an XmlDataDocument and put the resulting transformed data back into another...
0
by: gilly3 | last post by:
Reposting to a more relevant group. I am passing a generic dataset into a new XMLDataDocument and then parsing the XML with XSLT. The idea being that I can parse any dataset with the same xslt,...
1
by: sam | last post by:
i get the following error while reading an xml into a dataset The same table cannot be the child table in two nested relation is there a solution for it XmlDataDocument datadoc = new...
13
by: Jerry C | last post by:
I am using some sample code from gotdotnet to Create DataSet mappings from a xsd schema. I am geting this error. code and error below. I might mention there is also a publictypelibrary file with...
1
by: =?Utf-8?B?TmFjaA==?= | last post by:
Does any one have a sample how to go to a parent node and then retreive all the children nodes info for that particulir parent. Example you have products as a parent tree then you have sales for...
1
by: JD | last post by:
I have a DataGridView with a DataSet as DataSource. The user can update the contents of the DataGridView, and then click on a Save button to save the data to an XML file. When they click on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.