如何在E4X中删除XML节点上的属性?我以为这会更容易,但是我还没有找到任何例子。
我试过了:
delete xml.attribute("myAttribute");
这给了我以下错误:
TypeError: Error #1119: Delete operator is not supported with operand of type XMLList.
我尝试过:
xml.attribute("myAttribute") = null;
这会导致编译器错误。
在您的示例中,只需[0]
在结果XMLList中添加,以确保删除单个属性节点,它应该可以工作:
delete xml.@attributename[0];
实际上,对我来说delete
,XMLList
它也适用于简单的情况(没有复杂的e4x搜索结构):
var x:XML = <x><c a="1"/><c a="2"/></x>;
trace("0", x.toXMLString());
delete x.c.@a;
trace("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>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句