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.

0
Duck1 (5)
1/19/2004 11:56:25 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
255 Views

Similar Articles

[PageSpeed] 15

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
0
Oleg
1/20/2004 11:53:21 AM
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.

0
Duck1 (5)
1/20/2004 6:25:18 PM
Reply:

Similar Artilces:

Opening File using default viewer
Hello, how would I go about opening a file using the default viewer, so for example, if the file is a txt file, then notepad would open it. Or if it is an XML file, then maybe firefox woulld open it. I was hoping to use a CButton and if the user clicks on it, then it would grab the path specified and open the file with the corresponding viewer. thanks. Jon wrote: > Hello, how would I go about opening a file using the default viewer, so > for example, if the file is a txt file, then notepad would open it. Or > if it is an XML file, then maybe firefox woulld open it. > > ...

Use of Pop3 accounts for external email
We've been using a pop3/smtp account to recieve our external email. I've heard that using those is a bad idea for a buisness. I don't understand it that much and wondering what are the issues with pop3 and what is an alternative to recieve external mail if not using a pop3 account. We have Exchange 2003. The issue is the company can't archive all user's mail. You know, company's email is representing the company, so the company should keep it as archives. With POP3 email will be moved from server to the client. Instead, you can use IMAP, Exchange Server, or ...

Trouble with hyhens within text when using LOOKUP
I have two columns, each containing a list of part numbers. Some of the part numbers contain hyphens. I am using LOOKUP and/or VLOOKUP to determine if the value in one column exists in the other. This works great on non-hyphenated part numbers. However, it will not find or return the hyphenated part numbers from the specified arrays. As a test, I did a quick if statement to compare the instances of identical hyphenated values that exist in both columns. Those statements did not have a problem with the hyphens. Can anyone offer any help? If hyphens cannot be used in conjunction with the ...

failure of Open XML 1.1.4 to work
Version: 2004 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Previous versions of this worked fine. This version comes up with comment &quot;not enough memory&quot;. As I have 2mg Ram this seems strange. Any help appreciated. I'm afraid you haven't provided sufficient information for anyone to go on, especially since that message quite often has nothing to do with memory. For any questions of a technical or performance nature it's important that you specify your current update level of OS X as well as for Office. Exactly when does this messag...

Using formulas to filter
Is there a way to filter a list by formulas the same way the Data->Filter option works? I'd like to take the matrix: Col A Col B Col C Col D Col E ===== ===== ===== ===== ===== Smith 30 $104.2 Yes 52 Jones 31 $155.3 No 51 Jones 31 $422.2 Yes 49 Freer 31 $424.3 Yes 42 Waylan 30 $322.5 No 50 Smith 31 $288.3 Yes 49 etc. And, using a formula, filter on Col B = 31 to produce: Col AA Col AB ...

RE: Use that security update
--dedtgpho Content-Type: multipart/related; boundary="yzkfzsfqtv"; type="multipart/alternative" --yzkfzsfqtv Content-Type: multipart/alternative; boundary="qeviqcxczwaquy" --qeviqcxczwaquy Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Microsoft Consumer this is the latest version of security update, the "October 2003, Cumulative Patch" update which eliminates all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express as well as three newly discovered vulnerabilities. Install now to hel...

Name Range with using Data Form
I first created a variable with A1:D1, four columns with named variable Data. How to expand this Data range to A1:D2 after using the DataForm to add one row data in the worksheet?? The same, the Data range should be A1:D3 when adding one more data row... million thanks Hi use the following formula in the name definition dialog =OFFSET($A$1:$D$1,0,0,COUNTA($A:$A)) >-----Original Message----- >I first created a variable with A1:D1, four columns with named variable >Data. How to expand this Data range to A1:D2 after using the DataForm to add >one row data in the worksheet?? The...

Has anyone used the Remove MO Utility?
I have a closed Quick MO that did not process properly somehow. The MO is flagged as closed, but sime items were not issued and are stuck in WIP. I ran the Tools > Utilities > Manufacturing > Remove MO process in a test database. It removed the MO and the items re no longer hung up in WIP. Has anyone else ever executed this process? Are there any gotcha's I need to be aware of? Many Thanks. Jim Hi Jim, I too have used this in a development/test environment and have not encountered any problems. -Mike -- Micheal LoPatriello Coordinator, Luna Development mlopat@lu...

How to use CxImage?
Hi I want to display a jpeg picture by using CxImage but I am new to visual c++ so I couldn't understand how to use this class in my project.Is there someone who have used this class and can you help me about using it? Thanks On Jul 3, 7:12 am, ibrahim <ibra...@discussions.microsoft.com> wrote: > Hi > I want to display a jpeg picture by using CxImage but I am new to visual c++ > so I couldn't understand how to use this class in my project.Is there someone > who have used this class and can you help me about using it? > Thanks Its all here: http://www.codeproj...

buy from this E-hermesol company is fast only used my 5days
I would like to introduce you a very good company which I knew. Their company homepage is www.ehermesol.com. They can offer you all kinds of electronical products which you need, such as motorcycles, laptops, mobile phones, digial cameras, TV LCD ,x box, ps3, gps, MP3/4, etc. Please take some time to have a look at it, there must be something you 'd like to purchase. Their contact email: ehermesol@188.com MSN: ehermesol@hotmail.com Hope you have a good mood in shopping from their company! Regards ...

How to use MSExcel to plot Column A against Col B?
I want to plot col A (x axis) against col B ( y axis). I cant seem to do it. Can anyone here please give me step by step primer. Thanks in advance. All I get is the graph of (1,2,............n) (x axis) against the n values of either col A or B. i.e 2 graphs instead of one. (In the old Lotus this was so simple: select the column for the X axis and then select the col for the Y and press enter, and you'd get the chart) Why is it so diff in Excel? Select the entire range you want to graph such as a2:b44>insert>chart>>>> -- Don Guillett SalesAid Software dguillett1@au...

HOWTO create a Mail Merge Template in MSCRM with multiple child records
Hi, I have created successfully a basic Mail Merge template in MS Word in Dynamics CRM 4.0 for Order Entity. My challenge now is how to design a template that retrieves the order details (product and prices) related to the order record? This sounds like a parent-child template. Any idea? On Jun 2, 1:26=A0pm, "Benjie Fallar III" <bfall...@hotmail.com> wrote: > Hi, > I have created successfully a basic Mail Merge template in MS Word in > Dynamics CRM 4.0 for Order Entity. > My challenge now is how to design a template that retrieves the order > details (prod...

Using cell text in a formula
I am trying to use derived cell references in a VLOOKUP formula to matc data in several tables. For example, A1 contains the cell reference fo the top left of my array (A3) whilst cell A2 contains the cel reference for the bottom right of my array (D14). The array I' checking against starts in column E3. However, when I use the formula =VLOOKUP(E3,A1:A2,4,FALSE) I get a #N/ error. I need to use the cell references in each VLOOKUP as the arra sizes may vary in each case. (PS, I've used =INDIRECT(ADDRESS(A1,A2) to derive the cell references. Ji -- Message posted from http://www.Excel...

Using two conditions in a formula
How do I write the following formula: I am in cell I6 If g6 AND h6 is blank, then blank, else I5 minus g6 plus h -- Richard Pit ----------------------------------------------------------------------- Richard Pitt's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1533 View this thread: http://www.excelforum.com/showthread.php?threadid=27042 Richard, In cell I6, enter the formula: =IF(AND(G6="",H6=""),"",I5-G6-H6) Though you don't check for case when G6 is blank and H6 isn't, etc. HTH, Bernie MS Excel MVP "Richard ...

Using Outlook to access and compile information in calendar
I want to create an application that will compile schedule information from Excel worksheets or an Access database and display them in a calendar type format. I know this type of application can be built using PivotTables in Excel, or forms in Access, but I was wondering if I could use the calendar in Outlook to display the information rather than creating PivotTables or custom forms which would wind up looking something like a calendar anyway. Before I start the job I'd like to know if I can work Outlook into the equation or if I really have to build it from scratch. Thanks, JEM ...

Using CMFCToolBar and CMFCMenuBar?
After initial frustrations indicated by recent messages, I am now getting on with these classes relatively cordially. The user of my program can add or remove buttons to/from the CMFCToolBar(s), and menu items to/from the CMFCMenuBar - all beautifully customisable. The program knows about the available commands and they can be added to any toolbar or menu. And new custom tool bars can be added by the user. It's all fiendishly clever. However: my questions (today) are as follows: 1. The MFC Customise dialogue, from which one can drag commands to toolbars and menus,...

XML extension cause file download loop
All, Suddenly. When I click on an XML file expecting it to open in IE, it begins the file download screen, then attempts to open IE. These 2 screens flash in an endless loop. What's up with that??? Any ideas are welcome! Thanks -- Mike Gasperino Sr. Software Developer office: 919-807-2310 Helpdesk: (919)807-2300 doa.helpdesk@ncmail.net **************************************************************************** E-mail correspondence to and from this address may be subject to the North Carolina Public Records Law "NCGS.Ch.132" and may be disclosed to third parties *****...

xml & script languages
I need some literature of integration of XML with script language! Any links? Thanks! mgalesic wrote: > I need some literature of integration of XML with script language! Wich script language? Do you want to use it on the Server (PHP, JSP, ASP, ASP.NET, Perl, Ruby,...) or on the Client (JavaScript & XmlDOM)? -- Pascal Schmitt Pascal Schmitt wrote: > mgalesic wrote: > >> I need some literature of integration of XML with script language! > > > Wich script language? > > Do you want to use it on the Server (PHP, JSP, ASP, ASP.NET, Perl, > Ruby,.....

How did you add text into publisher, without using boxes?
how do you add text to publisher without using text boxes I suppose you could create your text as an image and insert the image into your publisher file. -- Don Vancouver, USA "Calvin Scott" <Calvin Scott@discussions.microsoft.com> wrote in message news:64D23D52-138D-47B4-B265-4A41BF14BF55@microsoft.com... > how do you add text to publisher without using text boxes Calvin Scott <Calvin Scott@discussions.microsoft.com> was very recently heard to utter: > how do you add text to publisher without using text boxes You don't. Text in Publisher has to e...

I want to design both side of a post card using publisher 03
I have go side one completed. How do I do the other side??? Insert Page -- Don Vancouver, USA "bettboop" <bettboop@discussions.microsoft.com> wrote in message news:68D78C55-BB03-44EC-97AF-D8FBA74FB95C@microsoft.com... >I have go side one completed. How do I do the other side??? ...

How to create an XML document with XmlTextWriter?
Hi, I'm trying to create an XML document with XMLTextWriter but I want to store it in memory (not write it to a file like so many examples do). I tried the following but with no luck. Should I not user this object for this purpose? Thanks, Dave MemoryStream stm = new MemoryStream() XmlTextWriter writer = new XmlTextWriter(stm, System.Text.Encoding.UTF8) writer.WriteStartDocument() writer.WriteComment("This Is A List of My Books") writer.WriteStartElement("MyBooks") writer.WriteStartElement("Book") writer.WriteAttributeString("ISBN", "1861005...

Using Outlook over a Network
Hi, I would like to know what software I need to allow multiple users to access one MS Outlook Calendar. The computers currently have Outlook 2000 and I would like the users to be able to edit one central calendar simultaneously, directly in the calendar (ie. not requiring users to send emails etc.) What sofware beyond Outlook 2000 do I need and is there any info on how this is done? Thanks Adrian Check out http://www.slipstick.com/outlook/share.htm -- PATRICK REED [Outlook - MVP]~~~~~~ -Microsoft Certified Professional (MCP) -Have you checked http://www.slipstick.com? -Plea...

how to use 2007 styles in Word 2003
hi everyone, we have Word 2003 but we really like the Styles that come with Word 2007. Is it possible to export these Styles and use it in Word 2003? And if yes, how can i do that. In Word 2007, click the Home tab of the ribbon. In the Styles group, click Change Styles | Style Set | Word 2003. To make this choice the default, click Change Styles again, and then click Set as Default. If/when you are prompted to save the changes to your template, choose to do so. -- Stefan Blom Microsoft Word MVP "skoub" <skoub@discussions.microsoft.com> wrote in messa...

How is the ease of use for salespeople compared to other tools?
With the goal of keeping it simple, it seems like there are a lot of steps, drop downs, etc. that slow up the inputting of information. Is there customization that is needed to speed this up would you think? is this a crm 1.2 or 3.0 question. Microsoft made a big effort to reduce the time to navigate around and input data in crm 3.0. you always have the option of building custom forms to allow you to enter data quickly then have these populate crm ========================= John O'Donnell Microsoft CRM MVP http://www.microsoft.com/businesssolutions/crm/community/microsoft_crm_co...

how can i use countif function inside a filtered range
How can I use countif function inside a filtered range Hi, Not much detail here, so this is the general idea: =SUMPRODUCT(SUBTOTAL(3,OFFSET(C13:C18,ROW(13:18)-13,0,1)),--(C13:C18="Red")) -- If this helps, please click the Yes button Cheers, Shane Devenshire "jayin" wrote: > How can I use countif function inside a filtered range Shane Devenshire wrote on 02/24/2009 02:05 ET : > Hi, > > Not much detail here, so this is the general idea: > > =SUMPRODUCT(SUBTOTAL(3,OFFSET(C13:C18,ROW(13:18)-13,0,1)),--(C13:C18=&quot;Red&quot;)) > > ...