Solved

XML reading in C#

Posted on 2011-03-24
5
315 Views
Last Modified: 2013-12-17
How can I read an XML file in C# with this format?

<column name="Year"><![CDATA[2000]]></column>
<column name="Make"><![CDATA[Cadillac]]></column>
<column name="Model"><![CDATA[Deville]]></column>
<column name="Price"><![CDATA[$10,525]]></column>

Open in new window


I want to read the fields instead of parsing the entire XML and process each entry...
0
Comment
Question by:evo_x
  • 2
  • 2
5 Comments
 
LVL 19

Expert Comment

by:Rikin Shah
ID: 35212912
<column name="Year" data="<![CDATA[2000]]>" />
<column name="Make" data="<![CDATA[Cadillac]]" />
<column name="Model" data="![CDATA[Deville]]" />
<column name="Price" data="<![CDATA[$10,525]]" />

Open in new window


Now you can easily access "data" from the xml.

http://support.microsoft.com/kb/307548
0
 
LVL 19

Expert Comment

by:Rikin Shah
ID: 35212915
Missed some codes.. :)

 
<column name="Year" data="<![CDATA[2000]]>" />
<column name="Make" data="<![CDATA[Cadillac]]>" />
<column name="Model" data="<![CDATA[Deville]]>" />
<column name="Price" data="<![CDATA[$10,525]]>" />

Open in new window

0
 
LVL 2

Author Comment

by:evo_x
ID: 35212925
there is an example of how to read raw xml data, but not the fields with ![CDATA[]...
0
 
LVL 9

Accepted Solution

by:
mayank_joshi earned 500 total points
ID: 35212932
you can use DataSet.ReadXml Method for that
eg,

String MyXml = "<MyTable><ID>1</ID><ParentID>2</ParentID><Name>Test</Name></MyTable>";

StringReader SR = new StringReader(MyXml);

DataSet ds = new DataSet();
ds.ReadXml(SR);

Open in new window

0
 
LVL 2

Author Comment

by:evo_x
ID: 35212958
I think this is what I need.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question