문제

I have a simple example

var myXML:XML =
<root>
    <element type="a">I am a</element>
    <element type="b">I am b</element>
</root>
;

I cant work out how I can programatically remove an element of a specific type

delete myXML.root.element.type['a'][0];
도움이 되었습니까?

해결책

To remove a XML element by matching an attribute of that element, I believe you're looking for:

var index:int = myXML.element.(@type=="b").childIndex();
delete myXML.element[index];

Based upon your XML:

var myXML:XML =
    <root>
        <element type="a">I am a</element>
        <element type="b">I am b</element>
    </root>;

After calling this function, the XML would be:

<root>
  <element type="a">I am a</element>
</root>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top