日期:2014-05-20  浏览次数:20384 次

xml读取节点属性问题
初学,麻烦大家指导一下,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 "));
               
                ???......

        }

------解决方案--------------------
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> "); }