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
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