Solved

XML reading in C#

Posted on 2011-03-24
5
311 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now