Reputation: 37
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
Upvotes: 0
Views: 75
Reputation: 4340
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("");
Upvotes: 1
Reputation: 1193
Why you need Empty node? But still if you want it do like so,
Assuming your xml has only one node,
var xml:XML = <item label="">R1</item>
xml.replace(0, <item></item>);
Upvotes: 0