如何解决此异常:
System.Xml.XPath.XPathException
我的代码是:
open(..., 'rb')
这是我的xml文件:
for (var d = 0; d < children1.Count; d++) //lista doc 1
{
var child = children1[d];
XmlNode nodeToFind = root.SelectSingleNode("/data[@name]" + child.Attributes["name"].Value);
if (nodeToFind == null){}
答案 0 :(得分:5)
您需要在方括号中使用要查找的值:
root.SelectSingleNode("/data[@name='" + child.Attributes["name"].Value + "']");