你的XML不是很规范,TABLE1,TABLE2之间应该还有一级,DOM可以很好的工作

解决方案 »

  1.   

    Try to use XmlDocument class, call SelectNodes method and give a XPath string parameter to get the data of Table1 and Table2. And use Save method to save XML to a file.Hope it could be help.
      

  2.   

    用 VS.NET 打开这个文件然后让 VS.NET 帮你整理一下结构使用的时候跟使用数据库一样readxml 方法读入 dataset 然后就可以用了,两个数据表都在里面了
      

  3.   

    assume your xml is "TestTable.xml" (your original xml is invalid):<table>
    <table1 table1ID="1">
    <Name>Name</Name>
    <table1name>1000</table1name>
    </table1>
    <table1 table1ID="2">
    <Name>Name</Name>
    <table1name>1000sdf</table1name>
    </table1>
    <table1 table1ID="3">
    <Name>Namefdfd</Name>
    <table1name>1sdf0sdf0</table1name>
    </table1>
            <table2 table2ID="1">
      <GroupName>sfasdf</GroupName>
    <Emails>[email protected]</Emails>
    </table2>
    <table2 table2ID="2">
    <GroupName>asdfatrasersfda</GroupName>
    <Emails>[email protected]</Emails>
    </table2>
    </table>tryusing System.Data;
    using System;class TestTable
    {
      public static void Main()
      {
    DataSet ds = new DataSet();
    ds.ReadXml("TestTable.xml");
    for (int i=0; i < ds.Tables.Count; i++)
    {
      Console.WriteLine(ds.Tables[i].TableName);
      for (int j=0; j < ds.Tables[i].Columns.Count; j++)
    Console.Write(ds.Tables[i].Columns[j].ColumnName+"\t");
    Console.WriteLine();
      foreach (DataRow dr in ds.Tables[i].Rows)
      {
          for (int j=0; j < ds.Tables[i].Columns.Count; j++)
    Console.Write(dr[j]+"\t");
    Console.WriteLine();
      }
    }
      }
    }