Search code examples
xmlactionscript-3apache-flexflex4flash-builder

In Xml remove node value not the entire node


In Xml How to remove node value in flex4.

Here it is the example.This is my xml node.

<item label="">R1</item>.

I want remove R1 in the above xml.

I need the output like this <item label=""></item> or <item label=""/>. This is possible? if Possible Please help me.

<result>
  <item label="Room3">

    <item>G140213003048</item>
  </item>
  <item label="Room4">Room4</item>
  <item label="Room8">Room8</item>
  <item label="Room149">Room149</item>
  <item label="Room53">Room53</item>
</result>

How To remove empty space in xml.@Adrian Pirvulescu


Solution

  • Yes it is possible.

    Considering your xml is declared like this

    var myXML:XML = new XML(<item label="">R1</item>);
    

    You can do the following:

    myXML.setChildren("");
    trace(myXML.toXMLString());
    

    -- Output: <item label=""></item>

    UPDATE

    Since you updated your example I need to update my post as well. Since you want to remove only in nodes where @label is "" then you can use the following.

    resultXML..item(@label == "").setChildren("");