XML Attributes in a DataSet

R

Ryan Rogers

How can one extract the Attribute values from a Dataset that has been loaded
with an XML file like the following at the bottom of the document. I have
to use a dataset and the XML file must remain the same?

Regards,
Ryan

<?xml version="1.0" encoding="utf-8" ?>
<Groups>
<Group Name="Information Technology" ID="IT" Description="Information
Technology" />
<Group Name="Finance" ID="Fin" Description="Finance Group"></Group>
<Group Name="Hyperion" ID="Hyp" Description="Individuals requiring access
to Hyperion."></Group>
<Group Name="Legal" ID="Leg" Description="Legal"></Group>
</Groups>
 
G

Guest

Hi Ryan,

Can u explain in a bit more details what u intend to do. I think you are able to read the xml file into a dataset...is it.Then u only need to iterate thru the rows collection of the datatable to find the values of the attributes of wach record.
 
C

Chris Bilson

If you are creating the DataSet manually:

DataSet ds = new DataSet();
DataTable groups = ds.Tables.Add("Groups");
groups.Columns.Add("Name", typeof(string)).ColumnMapping
= MappingType.Attribute;

....however, using a (XSD) schema would be my preferred method. That way
you (and whoever create the XML to start with) could agree on the format
of the XML even if you are not both using the same platform or
technology. With a schema, I would just generate a typed dataset.


--Chris Bilson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top