刚开始我第一次参加XPathNavigator
.
这是我的简单 xml:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<theroot>
<thisnode>
<thiselement visible="true" dosomething="false"/>
<another closed node />
</thisnode>
</theroot>
现在,我正在使用该CommonLibrary.NET
库来帮助我一点:
public static XmlDocument theXML = XmlUtils.LoadXMLFromFile(PathToXMLFile);
const string thexpath = "/theroot/thisnode";
public static void test() {
XPathNavigator xpn = theXML.CreateNavigator();
xpn.Select(thexpath);
string thisstring = xpn.GetAttribute("visible","");
System.Windows.Forms.MessageBox.Show(thisstring);
}
问题是它找不到属性。我已经为此查看了 MSDN 上的文档,但对正在发生的事情不太了解。