【发布时间】:2016-06-26 22:33:58
【问题描述】:
我有这个 XML
<WordDefinition>
<Word>analyses</Word>
<Definitions>
<Definition>
<Word>analyses</Word>
<Dictionary>
<Id>wn</Id>
<Name>WordNet (r) 2.0</Name>
</Dictionary>
<WordDefinition>analyses
See {analysis}
</WordDefinition>
</Definition>
<Definition>
<Word>analyses</Word>
<Dictionary>
<Id>wn</Id>
<Name>WordNet (r) 2.0</Name>
</Dictionary>
<WordDefinition>analysis
n 1: an investigation of the component parts of a whole and their
relations in making up the whole
</WordDefinition>
</Definition>
</Definitions>
</WordDefinition>
我编写了这个 C# 来获取“WordDefinition”的 innerText,如果只有一个“wordDefinition”,它就可以正常工作。但是,如果有 一个或多个,我想获取最后一个的 innerText。
var doc = new XmlDocument();
doc.LoadXml(responseFromServer);
var el = doc.GetElementsByTagName("WordDefinition");
有人知道我该怎么做吗?对于这个例子,我想得到这个的 innerText:
<WordDefinition>analysis
n 1: an investigation of the component parts of a whole and their
relations in making up the whole
</WordDefinition>
【问题讨论】:
-
看看this话题。您可能有兴趣。尝试我的答案中的方法,而不是手动获取响应。