<mcs type="form">
     <head>
        <title>表单测试</title>
    </head>
     <body>
         <font>text<font/> 
         <font align="left" id="1" value="民意调查"/>
         <font align="left" id="2" value="公司开放体育馆和食堂及时间"/>
         <input type="text" id="3" name="text1" />
         <font align="left" id="4" value="这个可以选择么"/>
         <select name="select2" id="5" caption="请选择日期">
         </select>
         <input type="radio"  id="6" name="radio1" value="同意" check="true" />
        
         <br type ="br"/>
         <hr type="hr"/>
     </body>
</mcs>我要把<font>text<font/> 中的font解析出,而不是解析text,<input type="text" id="3" name="text1" />中的input解析出来,<select name="select2" id="5" caption="请选择日期"></select> 把select解析出

解决方案 »

  1.   

    本帖最后由 net_lover 于 2011-10-12 14:47:14 编辑
      

  2.   

      <font>text<font/>  
    改成
      <font>text</font>  
      

  3.   

    XmlDocument 的 SelectSingleNode 只能解节点的值如<font>text</font> 中只能解出text, 不能得到font这样的结果,请给你相关代码,最好测试过的,thank you!
      

  4.   

    XmlNode n = doc.SelectSingleNode("//font");
    n.OuterXml就是啊
      

  5.   

    XmlElement xe = doc.SelectSingleNode();Console.WriteLing(xe.Name)
      

  6.   

    4楼的方法行不通,它会把所有的都打出来,得到的结果是<font>text</font> ,这不是本贴所需的结果,我要的结果是font,请给相关代码,最好测试过的,thank you!
      

  7.   

    XmlNode n = doc.SelectSingleNode("//font");
    n.Name
    结合一下就可以了
      

  8.   

    只要节点名?
                    XmlDocument xml = new XmlDocument();
                    xml.Load(@"E:\1.xml");
                    XmlNode font = xml.SelectSingleNode("//font[text()='text']");
                    Console.WriteLine(font.Name);
                    XmlNode input = xml.SelectSingleNode("//input[@type='radio' and @id='6' and @name='radio1']");
                    Console.WriteLine(input.Name);
                    XmlNode select = xml.SelectSingleNode("//select[@name='select2' and @id='5']");
                    Console.WriteLine(select.Name);
      

  9.   

    不明白你要实现什么目的,你都知道了font还得到font做什么呢?
    你看看.net sdk中的XmlNode类没有?
      

  10.   

    后台传出来的数据你不知道是什么节点名,这只不过举个例子刚好是font, 也有可能是foot, ipone, 什么都可能,所以要把节点名解析出来,呵呵!