Search code examples
xmlactionscript-3flashclone

Failed to copy Xml as3


I am working on as3 project in which i am using XML.I am facing an issue when I copy an xml object to other (newxml=oldxml) the text is copied but if I delete some node from oldxml It automatically delete that node from copied variable (newxml).

Code for deleting node:

for each( node in xmlold.links.slidelink.(@displaytext.toLowerCase().indexOf(this.searchbar.text.toLowerCase())<0))
{

var index = node.childIndex();



   delete xmlold.links.slidelink[index];
   }

    this.display.text=xmlnew.toString();

Now when I display text if "xmlnew" It give me output after deleted text which is not required

Xml Look like:

<outline xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <links>
    <slidelink slideid="_player" displaytext="Headd"    <slidelink slideid="5pnZ9Eziqq4" displaytext="Relationship" expand="true" type="slide"/>
    <slidelink slideid="vgVg68B" displaytext="Temperature Relationship" expand="true" type="slide"/>
    <slidelink slideid="_player" displaytext="Viscosity" expand="true" type="slide"/>
  </links>
</outline>

Please check the problem Your help will really appreciated thanks


Solution

  • newxml=oldxml does not copy, it simply says "newxml is same thing as oldxml".

    You need something like newxml = new XML (oldxml);

    As a starting point try:

    var newxml : XML = new XML ( oldxml.toXMLString() );