【发布时间】:2015-02-02 08:42:21
【问题描述】:
我正在尝试从此 XML 文档中获取子项:
此处为 XML 代码:
<RUNNABLES>
<RUNNABLE-ENTITY UUID="1661dcae-c4b9-4f47-8b68-cb99c677bdd6">
<SHORT-NAME>RCtApElg_mlm</SHORT-NAME>
<DESC>
<L-2 L="FOR-ALL">The unique runnable entity of the Main Lights SW Component</L-2>
</DESC>
</RUNNABLES>
到目前为止,这是我所做的:
这里是C#代码
XmlDocument xmlReader = new XmlDocument();
xmlReader.PreserveWhitespace = false;
xmlReader.Load(strfilename);
XmlNodeList elemList = xmlReader.SelectNodes("/RUNNABLES/RUNNABLE-ENTITY/SHORT-NAME");
如何指定读取 SHORT-NAME 标记并获得“RCtApElg_mlm”值作为结果?
【问题讨论】:
-
改用
SelectSingleNode怎么样?
标签: c# parsing xmldocument