【发布时间】:2011-12-01 11:15:17
【问题描述】:
我想使用以下代码更新 XDocument
private static bool ResetUpdateVersion()
{
// this indicate either the verwsion is different or not
// this will either call the update only or writting the defualt
bool Result = false;
//// check for version using xpath
XPathNavigator navigator = document.CreateNavigator();
//ShortcutList is the main element that contain all the other elements
XPathNavigator node = navigator.SelectSingleNode(@"/ShortcutList");
XmlNamespaceManager ns = new XmlNamespaceManager(navigator.NameTable);
if (node != null)
{
if (node.GetAttribute("Version", ns.DefaultNamespace) != Version)
{
node = navigator.SelectSingleNode(@"/ShortcutList/@Version");
node.SetValue( Version);
Result = true;
}
else
{
Result = false;
}
}
return Result;
}
但它在node.SetValue( Version); 线上引发了 NotSupportedException,我不知道为什么,有什么办法解决这个问题
【问题讨论】:
-
什么是版本?它是在哪里定义的?
标签: xpath c#-3.0 xpathnavigator