Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.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
Actionscript 3 如何删除XML中的属性?_Actionscript 3_Flash_E4x - Fatal编程技术网

Actionscript 3 如何删除XML中的属性?

Actionscript 3 如何删除XML中的属性?,actionscript-3,flash,e4x,Actionscript 3,Flash,E4x,如何在E4X中删除XML节点上的属性?我认为这会更容易,但我还没有找到任何例子 我试过: delete xml.attribute("myAttribute"); 这给了我以下错误: TypeError: Error #1119: Delete operator is not supported with operand of type XMLList. 我试过: xml.attribute("myAttribute") = null; 这会导致编译器错误。在您的示例中,只需在生成的XML

如何在E4X中删除XML节点上的属性?我认为这会更容易,但我还没有找到任何例子

我试过:

delete xml.attribute("myAttribute");
这给了我以下错误:

TypeError: Error #1119: Delete operator is not supported with operand of type XMLList.
我试过:

xml.attribute("myAttribute") = null;

这会导致编译器错误。

在您的示例中,只需在生成的XMLList中添加
[0]
,以确保删除单个属性节点,它应该可以工作:

delete xml.@attributename[0];
实际上,对于我来说,使用
xmlslist
delete
也适用于简单的情况(没有复杂的e4x搜索结构):

var x:XML=; 跟踪(“0”,x.toXMLString()); 删除x.c.@a; 跟踪(“1”,x.toXMLString()); 输出:

[trace] 0 <x>
[trace]   <c a="1"/>
[trace]   <c a="2"/>
[trace] </x>
[trace] 1 <x>
[trace]   <c/>
[trace]   <c/>
[trace] </x>
[trace]0
[跟踪]
[跟踪]
[跟踪]
[跟踪]1
[跟踪]
[跟踪]
[跟踪]

My属性位于根节点上。如果你把
a
放在
x
上,你会得到我在OP中提到的错误吗?对于根属性,这对我来说和我的示例中一样有效,这一切都很好(我在SDK 3.6A和SDK 4.6上检查过)。你使用哪个SDK?我也使用4.6。现在可以了。我与早期版本进行了比较,并尝试了
删除xml.attribute(“myAttribute”)但未尝试
删除xml。@myAttribute就像你的答案一样。谢谢
[trace] 0 <x>
[trace]   <c a="1"/>
[trace]   <c a="2"/>
[trace] </x>
[trace] 1 <x>
[trace]   <c/>
[trace]   <c/>
[trace] </x>