zoukankan      html  css  js  c++  java
  • 有关xml操作的心得(2)--xml文件和数据显示控件的绑定

    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】出现这个嵌套内容的显示

  • 相关阅读:
    hdu 4027 Can you answer these queries?
    Codeforces: Empty Triangle
    hdu 3006 The Number of set
    hdu 3645 Code Management System
    进度条作控件代码
    NORMAL
    callback
    三种形状匹配脚本
    移动点动画
    脚本管理
  • 原文地址:https://www.cnblogs.com/ocean2000/p/455514.html
Copyright © 2011-2022 走看看