zoukankan      html  css  js  c++  java
  • c#操作XML

    using System.Xml;
    
     XmlDocument xdTree = new XmlDocument();
            xdTree.Load(Server.MapPath("~/TreeView.xml"));//读取XML文件
            XmlElement xmlNew=xdTree.CreateElement("siteMapNode");//创建节点
            xmlNew.SetAttribute("title",cate.Name);
            xmlNew.SetAttribute("url","BookList.aspx?typeid=1");//+cate.Id.ToString());
            xmlNew.SetAttribute("description","");        
            xdTree.SelectSingleNode("siteMapNode").AppendChild(xmlNew);//将节点值添加到节点
            xdTree.Save(Server.MapPath("~/TreeView.xml"));//保存XML文件
     
     <?xml version="1.0" encoding="utf-8" ?>
    - <siteRoot Id="root" url="" title="管理员控制面板" description="">
    - <siteMapNode url="" title="用户管理" description="">
      <siteMapNode url="~AdminListAllUsers.aspx" title="管理用户" description="" />
      <siteMapNode url="~AdminUserStatue.aspx" title="状态管理" description="" />
      <siteMapNode url="~AdminListAllUsers.aspx" title="用户列表" description="" />
      </siteMapNode>
    - <siteMapNode url="" title="图书分类管理" description="">
      <siteMapNode url="~AdminAddBooksCatagory.aspx" title="添加图书分类" description="" />
      <siteMapNode url="~AdminListBooksByCategory.aspx" title="为书籍分类" description="" />
      <siteMapNode url="~AdminListOfBooks.aspx" title="书籍列表" description="" />
      </siteMapNode>
    - <siteMapNode url="" title="定单管理" description="">
      <siteMapNode url="~AdminCheckOrders.aspx" title="审核定单" description="" />
      </siteMapNode>
      <siteMapNode url="~AdminLoginOut.aspx" title="退出" description="管理员退出" />
      </siteRoot>
  • 相关阅读:
    sizeof()和 strlen()的区别 --- 个人笔记
    MySQL 生成自增流水号
    sql 逗号分隔列转行
    【转】.NET中lock的使用方法及注意事项
    【转】在一个SQL Server表中一行的多个列找出最大值
    使用 PIVOT 和 UNPIVOT
    List<T>转DataTable
    C# 分数计算类(加减乘除)
    【转】mysql执行计划介绍
    【转】SQL Server 存储:理解IAM 页
  • 原文地址:https://www.cnblogs.com/qigege/p/4750042.html
Copyright © 2011-2022 走看看