Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to remove xml tag using as3
    primarykey
    data
    text
    <p>I have exported data .xls file using as3.</p> <pre><code>var xml:ArrayCollection; xml=Labneuron8.lastResult.Response.Terminal as ArrayCollection; var str:String=xml[0].Value; var xml1:XML=new XML(str); myData=new XMLListCollection(xml1.children()); var bytes:ByteArray = new ByteArray(); bytes.writeObject(myData.children().toString()); var f:FileReference = new FileReference(); f.save(bytes,"output.xls"); </code></pre> <p>while running a .xls file is created with values</p> <pre><code>&lt;Val&gt;0.307280&lt;/Val&gt; &lt;Val&gt;0.307280&lt;/Val&gt; &lt;Val&gt;0.307280&lt;/Val&gt; &lt;Val&gt;0.307280&lt;/Val&gt; &lt;Val&gt;0.307280&lt;/Val&gt; &lt;Val&gt;0.307280&lt;/Val&gt; ....... </code></pre> <p>Now I have to delete this Val tags, which is not required. </p> <p>Please let me know script to delete this tag.</p> <p>Thanks .............UPDATE................</p> <p>Now I modified the code as</p> <pre><code>var xml:ArrayCollection; xml=Labneuron8.lastResult.Response.Terminal as ArrayCollection; var str:String=xml[0].Value; var xml1:XML=new XML(str); var vals:XMLList = xml1.Val; for each(var val:XML in vals) { delete (val.parent().children()[val.childIndex()]); Alert.show("hi"); } myData=new XMLListCollection(xml1.children()); var bytes:ByteArray = new ByteArray(); bytes.writeObject(myData.children().toString()); var f:FileReference = new FileReference(); f.save(bytes,"output.xls"); </code></pre> <p>But the for each loop is not working.So I get the same output as before with val tags.How this can be solved? To delete an xml nodes, first you need to find them:</p> <pre><code>var sourceXML:XML = ... var vals:XMLList = sourceXML.Val; //enter actual path to Val nodes here </code></pre> <p>Then you delete each one using parent:</p> <pre><code>for each(var val:XML in vals) { delete (val.parent().children()[val.childIndex()]); } </code></pre> <p>If all your nodes have same parent, you can cache val.parent().children() in local variable, so it will be faster.</p> <p>..................UPDATE...................</p> <p>@Patrick</p> <pre><code>var xml:ArrayCollection; xml=Labneuron8.lastResult.Response.Terminal as ArrayCollection; var str:String=xml[0].Value; var xml1:XML=new XML(str); xml1..Val.(parent().replace(valueOf().childIndex(),valueOf().text())) myData=new XMLListCollection(xml1.children()); var bytes:ByteArray = new ByteArray(); bytes.writeObject(myData.children().toString()); var f:FileReference = new FileReference(); f.save(bytes,"output.xls"); </code></pre> <p>...............SOLUTION ....................</p> <pre><code>var xml6:ArrayCollection; xml6=Labneuron8.lastResult.Response.Terminal as ArrayCollection; var str:String=xml6[0].Value; var xml1:XML=new XML(str); xml1..Val.(parent().replace(valueOf().childIndex(),valueOf().text()+"\n")) myData3=new XMLListCollection(xml1.children()); var bytes:ByteArray = new ByteArray(); bytes.writeObject(myData3.children().toString()); var fo:FileReference = new FileReference(); fo.save(bytes,"output.xls"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload