[英]c# xmlnode select single node to remove
I have an XML document that has nodes/values like this: 我有一个具有这样的节点/值的XML文档:
<data name="btnAutoTrans" xml:space="preserve">
<value>Auto Trans</value>
</data>
<data name="btnDieEngine" xml:space="preserve">
<value>Diesel Engine</value>
</data>
I need to select a single node for a specific name="btnDieEngine" (for example) 我需要为特定名称=“ btnDieEngine”选择一个节点(例如)
but all the code I have tried from searching google always returns NULL value. 但我尝试从Google搜索的所有代码始终返回NULL值。
The original code I had was 我原来的代码是
XmlNode node = xmldoc.SelectSingleNode("data[name='btnDieEngine']");
but this returns null. 但这返回null。
Any help would be appreciated 任何帮助,将不胜感激
Your XPath is invalid. 您的XPath无效。 Try that one: 试试那个:
XmlNode node = xmldoc.SelectSingleNode("data[@name='btnDieEngine']");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.