|
-
March 17th, 2009, 07:46 AM
#1
XML to DataSet - Problem
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
Last edited by Comand; March 17th, 2009 at 08:19 AM.
-
March 17th, 2009, 12:08 PM
#2
Re: XML to DataSet - Problem
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??
Last edited by Comand; March 18th, 2009 at 11:06 AM.
Reason: need help
-
March 18th, 2009, 11:07 AM
#3
Re: XML to DataSet - Problem
-
March 19th, 2009, 05:20 AM
#4
Re: XML to DataSet - Problem
Plz change this line
ds.ReadXml(xmlPath);
to
ds.ReadXml(Context.Server.Mappath(xmlpath);
rajesh
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|