xml文档不是很规范没怎么仔细考虑设计的合理性,文档如下
<?xml version="1.0" encoding="gb2312"?>
<files maxid ="002">
  <file>
    <name>新建文件夹</name>
    <id>001</id>
    <nodetype>02</nodetype>
    <author>system</author>
    <parentid>-1</parentid>
  </file>
  <file>
    <name>system2</name>
    <id>002</id>
    <parentid>-1</parentid>
    <nodetype>02</nodetype>
  </file>
</files>

当我用如下代码读入并绑定到datagrid发现
string mypath = Server.MapPath("A.xml");
DataSet myds 
= new DataSet();
myds.ReadXml(mypath);

DataGrid1.DataSource 
= myds;
DataGrid1.DataBind();
绑定后显示的内容确是

files_id

maxid

001

002

连我需要的file内容的影子都没有看到,后来经别人提示,才知道,file节点内容居然是放在dataset.tables[1],暂时没找到相关的帮助来帮我理解这个现象,只能记下来了。不过据我猜测,如果在file节点下面存在另外多个嵌套节点那么可能会在tables【3】出现这个嵌套内容的显示

posted on 2006-07-20 14:14  From Ocean  阅读(626)  评论(0编辑  收藏  举报