如何将xmlnode移到父级

编程入门 行业动态 更新时间:2024-10-10 07:21:42
本文介绍了如何将xmlnode移到父级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

脚本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移到父级

本文发布于:2023-11-11 08:23:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577874.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:移到   如何将   xmlnode

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!