Click to See Complete Forum and Search --> : XML to DataSet - Problem


Comand
March 17th, 2009, 07:46 AM
Hello,

I have a XML-File and I want to read the Information out of it.
Maybe my XML-File has failures....I don't know.
How can I get to "name1" and "123"?

<?xml version="1.0" standalone="yes"?>
<Characteristics>
- <PostalCodeCharacteristics>
- - <Characteristic name = "name1" value = "123"/>
- - <Characteristic name = "name2" value = "234"/>
- - <Characteristic name = "name3" value = "345"/>
- </PostalCodeCharacteristics>
- <TownCharacteristics>
- - <Characteristic2 name = "name1" value = "123"/>
- - <Characteristic2 name = "name2" value = "234"/>
- </TownCharacteristics>
</Characteristics>


My current Code:

public Test() {
- private DataSet ds = new DataSet();
- ds.ReadXml(xmlPath);
- string[] charNames = new string[100];

- int i = 0;
- string temp = "1";
- while (temp != "") {
- - temp = ds.Tables[i].ToString();
- - charNames[i] = temp;
- - i++;
- }
- DataTable tbl = ds.Tables[charNames[0]];
- int count = 0;
- foreach (DataRow row in tbl.Rows)
- - count++;
- nameList = new string[count];
- valueList = new string[count];

- for (int i = 0; i < count; i++) {
- - nameList[i] = ???
- - bitsList[i] = ???
- }
}


I know, that the "count"-variable is already wrong.
Please help!


EDIT: I'm using MS Visual Studio .NET 2003 / MS .NET Framework 1.1

Comand
March 17th, 2009, 12:08 PM
SOLVED with a new XML-File....

<Characteristics>
<PostalCodeCharacteristics>name1;123</PostalCodeCharacteristics>
<PostalCodeCharacteristics>name2;234</PostalCodeCharacteristics>
<PostalCodeCharacteristics>name3;345</PostalCodeCharacteristics>
<TownCharacteristics>name1;234</TownCharacteristics>
<TownCharacteristics>name2;345</TownCharacteristics>
</Characteristics>

EDIT: But nevertheless, can anyone say me, how to deal with the upper XML-File??

Comand
March 18th, 2009, 11:07 AM
Please, I need help!

rnsr
March 19th, 2009, 05:20 AM
Plz change this line
ds.ReadXml(xmlPath);

to

ds.ReadXml(Context.Server.Mappath(xmlpath);




rajesh