xml相关

<?xml version="1.0" encoding="utf-8" ?>
<controller>
  <form id="F01">
    <button id="B01" command="C">
      <next on="condition1" paramkey="P01" mode="Show" to="F02"/>
      <!--<end on="condition2"/>
   <fail on="condition3"/>-->
    </button>
    <button id="B02" command="C">
      <next on="condition1" paramkey="P02" mode="ShowDialog" to="F03"/>
    </button>
  </form>
  <form id="F02">
    <button id="B01" command="C">
      <next on="condition1" paramkey="P01" mode="Hide" to="F03"/>
    </button>
  </form>
</controller>
 

XmlNode xn = xmlDoc.SelectSingleNode(node);

XmlNodeList nodelist = xmlDoc.SelectNodes("//controller/form");

 

操作xml文件的类是 using System.Xml; 中的 XmlDocument

以下是一个简单的例子

XmlDocument xml = new XmlDocument();//新建xml对象

xml.Load("xml文件路径"); //载入xml文件路径

XmlNode node = xml.FirstChild; //获取文档的第一个节点

foreach (XmlNode n in node.ChildNodes)

{

        string v = n.Value; //节点的值

        string v1 = n.Attributes["属性名"].Value; //节点属性值

        string v2 = n["元素名"].Value; //元素值

        string v3 = n["元素名"].Attributes["属性名"].Value; //元素属性值

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值