<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解析出
<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解析出
改成
<font>text</font>
n.OuterXml就是啊
n.Name
结合一下就可以了
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);
你看看.net sdk中的XmlNode类没有?