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; //元素属性值

}

你可能感兴趣的:(xml,String,command,文档,button,encoding)