Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XpathNavigator引发错误NotSupportedException_Xpath_C# 3.0_Xpathnavigator - Fatal编程技术网

XpathNavigator引发错误NotSupportedException

XpathNavigator引发错误NotSupportedException,xpath,c#-3.0,xpathnavigator,Xpath,C# 3.0,Xpathnavigator,我想使用以下代码更新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

我想使用以下代码更新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(版本)行上引发NotSupportedException
,我不知道为什么,有什么办法可以解决这个问题,XDocument或XElement上的XPathNavigator是只读的,如果您想操作XDocument或XElement,那么就使用System.Xml.Linq中公开的API(例如)。

什么是版本?它的定义是什么?