【发布时间】:2016-08-15 12:42:56
【问题描述】:
我有一个 xml
<?xml version="1.0" encoding="utf-8"?>
<content>
<field title="Year">
<description>Numeric data</description>
<comment>1234</comment>
</field>
<field title="mail">
<description>Numeric data</description>
<comment>ABCD</comment>
</field>
<field title="Years">
<description>AlphNumeric Data</description>
<comment>ABCD1234</comment>
</field>
</content>
使用下面的代码,我提取 <description> 和 <Comment> 的节点值,它们位于属性 Title 下,Value='year'
XmlDocument xml = new XmlDocument();
XmlNodeList xnList = xml.SelectNodes("/contentr/field[@title='"+ searchdata +"']");
如果 searchdata = 'year' 那么 这将只提取值为'year'的属性的节点值。但我需要提取属性值包含'year'以及'years'的所有数据
有没有办法做到这一点?我正在开发 c#,ver 2.0
【问题讨论】: