Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

XML reading in C#

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
evo_x
Asked:
evo_x
  • 2
  • 2
1 Solution
 
Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:
<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
 
Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:
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
 
evo_xAuthor Commented:
there is an example of how to read raw xml data, but not the fields with ![CDATA[]...
0
 
mayank_joshiCommented:
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
 
evo_xAuthor Commented:
I think this is what I need.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now