473,698 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EnforceConst raints = false;
SqlDataAdapter da = new SqlDataAdapter( query, connStr);
da.Fill(ds, "Keywords") ;
XmlDataDocument xmlDoc = new XmlDataDocument (ds);
string s = xmlDoc.SelectSi ngleNode("NewDa taSet/Keywords/Entry").InnerTe xt;
s = UnConvertEntiti es(s);
xmlDoc.SelectSi ngleNode("NewDa taSet/Keywords/Entry").InnerXm l = s;

// UnConvertEntiti es(string s)
s.Trim();
s.Replace("&amp ;", "&");
s.Replace("&lt; ", "<");
s.Replace("&gt; ", ">");
s.Replace("&apo s;", "'");
s.Replace("&quo t;", "\"");
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 5482
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
1534
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
9564
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, XmlWriteMode.IgnoreSchema) I would like to add <?xml version="1.0" ?>
1
2086
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 .Net's XML Namespace and was wondering if someone could help with something....in the VB 6 application, we would append two extra nodes to the XMLRecordset-- an error message, and error number. Then, when it came time to reconstruct the recordset...
1
3267
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 DataSet or simply to modify the current DataSet. The first part is easy: Dim xmlDataDoc as XmlDataDocument = new XmlDataDocument(oracleDS) Dim xslTrans as XslTransform = new XslTransform
0
2154
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, and dynamically generate an html table. The problem is when the DataSet contains a null value, the node for that record is not created. Then when the xml parses it, there are too few cells in some of the table rows. I can think of a couple...
1
2608
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 XmlDataDocument() datadoc.LoadXml(xmlstring) ds = datadoc.DataSet;
13
2891
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 this file I may have to use it in some way. I am very new at XML so some examples or articles would be helpfull. The error is:
1
953
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 that particulair product in the child tree. for each product I would like to retreive all the sales Info dates in particulair. The tree is loaded But I need a way to retreive.
1
2878
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 Save, I call the subroutine below. The first time that I call it, it works fine. However, if the user makes some more changes in the DataGridView and then wants to save again, I get the following error message: "DataSet can be associated with at...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.