文件如:
<武侠传奇 text="2">
  <江湖行 value="2">测试</江湖行>
</武侠传奇>
................................
使用:
foreach (TreeNode node in TreeView1.CheckedNodes)
{            
   str += node.Value.ToString()+ ";";
   str += node.Text.ToString() + "<br>";
}
读出来得是:
武侠传奇;武侠传奇
.......................................
怎么才能读出来2这个value 值?????

解决方案 »

  1.   

    用XmlAttributeCollection就可以了!
    XmlAttributeCollection xmlAttr = xmlNode.Attributes;
    for (int i = 0; i < xmlAttr.Count; ++i)
    {
    if (xmlAttr.Item(i).Name == "武侠传奇")
    {
    this.Url = xmlAttr.Item(i).Value;
    break;}
    }
      

  2.   

    node.Attributes["text"].Value
    node.Attributes["value"].Value
      

  3.   

    编译器错误信息: CS0117: “System.Web.UI.WebControls.TreeNode”并不包含“Attributes”的定义
      

  4.   

    晕死.
    楼主循环的是treeview.而那是xml应该在绑定的时候把那两个值放在treenode.value中.如:
    绑定时treeNode.value = xmlNode.Attributes["text"].value+","+
    xmlNode.Attributes["value"].value;另外xmlNode.Attributes要先判断是否存在这个属性.
      

  5.   

    xmlNode这个属性,在哪里定义呢?怎么定义呢?