如果是简单的比如
<root>
<table>
<row><name>zhang ming</name></row>
<row><name>li lei</name></row>
</table>
</root>
这个可以直接用ds.table[0].rows来取每一行
可是如果是
<root>
<table>
<talbeinfo1>aaa</tableinfo1>
<talbeinfo2>aaa</tableinfo2>
<childtable>
<row><name>zhang ming</name></row>
<row><name>li lei</name></row>
<childtable>
</table>
</root>
怎么办了?

解决方案 »

  1.   

    if your xml is very complex, and DataSet's ReadXml will create multiple tablesfor an xml like yours, you should use classes under System.Xml, like XmlDocument or XmlTextReader depending on your usage and size of your xml content
      

  2.   

    dataset is only good to deal with simpler xml, if your xml is complex, use System.Xml.XmlTextReader or XmlDocument
      

  3.   

    用XmlDocumnet类吧 操作xml还是这个比较灵活 可以自己写递归遍历的
      

  4.   

    你的XML文件是不是由DataSet生成的,如果是的话再复杂的也可以用Dataset来访问,如果不是就只能借助XmlDocumnet 或 XmlTextReader 了