CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Mar 2009
    Posts
    7

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured