删除XML节点,保留原来的

发布于 2024-09-03 18:30:12 字数 117 浏览 10 评论 0原文

我需要从 XML 变量中删除一些节点,并且希望保持原始节点不变。
因此,我将 XML 传递给一个新变量,并从该变量中删除节点,但原始变量随之发生变化。

有没有办法保护 XML 免受原始变量的影响?

I need to delete some nodes from an XML variable and I want to keep the original intact.
So I pass the XML to a new variable and delete the nodes from that one but the original changes with it.

Is there a way to protect the XML from the original variable?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三寸金莲 2024-09-10 18:30:12

您想要克隆 xml,而不仅仅是设置另一个变量引用它。

尝试 var xmlbackup:XML = xml.copy();

you want to clone the xml, not just set another variable reference to it.

try var xmlbackup:XML = xml.copy();

泅渡 2024-09-10 18:30:12

我认为下一个代码也可以完成这项工作:

var newXML : XML = new XML(oldXML);

I think that next code do the job too:

var newXML : XML = new XML(oldXML);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文