脚本paltform是C#winform,现在我需要编辑一个xml文件. 我想将xmlnode移到他的父级,就像下面将B移到A的顶部一样: A | X-- | B 但我尝试使用"A.ParentNode.InsertBefore(B,A);",但失败了. 而且我曾尝试对A.parent使用克隆"或"AppendChild",然后对A使用"InterBefore",但都失败了...:confused: 正确的方法是什么?还是在同一xmldocument中移动不同级别的xlmnode有一些限制?
The script paltform is C# winform,now i need edit a xml file. i want move a xmlnode to his parent level,like below move B to the top of A: A | X--| B but i try as "A.ParentNode.InsertBefore(B, A);", but failed. And i had try to use "Clone" or "AppendChild" to A.parent then "InterBefore" to A, but all failed...:confused: Whats the correct way? or there are some limits on differen level xlmnode moving within same xmldocument?
推荐答案您可以尝试以下方法. You can try following. XmlNode parent = currentNode.ParentNode; //parent.RemoveChild(priusNode); //then use parent.InsertBefore method to move it.
HTH
HTH
更多推荐
如何将xmlnode移到父级
发布评论