初学,麻烦大家指导一下,xml文件如下
<?xml version="1.0" encoding="utf-8" ?>
<processes>
  <process id="1" name="请假流程" >
    <activity id="start" name="开始" activityType="1">
      <state>0</state>
      <people> qq </people>
      <Transition number="1" joinType="and ">
        <nextActivity id="A" />
      </Transition >
    </activity>
    <activity id="A" name="部门审核" activityType="1">
      <state>0</state>
      <people> uu </people>
      <Transition number="1" joinType="and ">
        <nextActivity id="B" />
      </Transition >
    </activity>
       <activity id="End" name="结束" activityType="1">
      <state>0</state>
    </activity>
  </process>
</processes> 
我想显示结果如下start-A-B ,start,A, B分别放在lable 里,用xmldocment ,没有查到相关用法,请教一下,有点着急!
 protected void Page_Load(object sender, EventArgs e)
    {
        XmlDocument xdoc = new XmlDocument();
        xdoc.Load = Xdoc.Load(Server.MapPath("work.xml"));
        
        ???......    }

解决方案 »

  1.   

    start-A-B 
    这三个节点并不是一个级别的,显示的规律是什么?
      

  2.   

    start 和 A 的节点是<activityB的节点是 nextActivity
      

  3.   

    是啊.要有规律才能写程序啊.
    第一个节点取他的id,第二个除了取ID外还要取他的子节点(transitino)的子节点(
    (nextActivity)的子节点.的id.这看不出规律来.
      

  4.   


    SORRY
    漏了<activity id="B" name="人事部审核" activityType="1">
          <state>0</state>
          <table> 人事部审核表 </table>
          <people> MM </people>
          <Transition number="1" joinType="and ">
            <nextActivity id="End" />
          </Transition >
        </activity>
      

  5.   

    有点手忙脚乱了,用xmlreader也可以吧
      

  6.   

    string str =@"<?xml version=""1.0"" encoding=""utf-8"" ?>
    <processes>
      <process id=""1"" name=""请假流程"" >
        <activity id=""start"" name=""开始"" activityType=""1"">
          <state>0</state>
          <people> qq </people>
          <Transition number=""1"" joinType=""and "">
            <nextActivity id=""A"" />
          </Transition >
        </activity>
        <activity id=""A"" name=""部门审核"" activityType=""1"">
          <state>0</state>
          <people> uu </people>
          <Transition number=""1"" joinType=""and "">
            <nextActivity id=""B"" />
          </Transition >
        </activity>
          <activity id=""B"" name=""人事部审核"" activityType=""1"">
          <state>0</state>
          <table> 人事部审核表 </table>
          <people> MM </people>
          <Transition number=""1"" joinType=""and "">
            <nextActivity id=""End"" />
          </Transition >
        </activity>  </process>
    </processes> ";

    System.Xml.XmlDocument dom = new System.Xml.XmlDocument();
    dom.LoadXml(str);
    System.Xml.XmlNodeList nl = dom.SelectNodes("//activity"); for(int i=0;i<nl.Count;i++)
    {
    Response.Write(nl[i].Attributes["id"].Value +"<BR>");
    }
      

  7.   

    谢谢你了,是这个意思,但是我想把它显示在lable里,好控制格式,
    lable1.text = ...?
      

  8.   

    var str = "";
    for(int i=0;i<nl.Count;i++)
    {
    str += nl[i].Attributes["id"].Value +" ");
    }
    label1.Text  = str;
      

  9.   

    因为我的文档里还有分支的情况,我的意思是将每一个都放在lable里,例如lable1显示start lable2显示A ,不知道能不能实现,谢谢你了。