If you don't wanna alter the original XML document,
use the XML "copy()" method to make a separate copy of the XML part you
wanna manipulate.
Here I wanna manipulate <page> node at index 2, so I use copy() there.
var targetNode:XML=doc.page[2].copy();
targetNode.setChildren("Replacement page content");
trace(targetNode.toXMLString());
//The original doc is left unchanged so you can refer back
//to it's elements all you want.
trace(doc.toXMLString();
-- Keith H --
www.keith-hair.net
Mark Carter wrote:
>
>
> Thanks for that keith, but that simply replaces the child nodes of the
> first
> page element with a new text node element. I want to reuse the old
> text node
> child of the first page element.
>
> khair wrote:
> >
> > var doc=
> > <book>
> > <toc/>
> > <toc/>
> > <page>Abc</page>
> > <page>123</page>
> > <page>XYZ</page>
> > <page>Last page</page>
> > <index />
> > <index />
> > </book>;
> >
> > var targetNode:XML=doc.page[2];
> > //Reference afterwards:
> > trace("--------targetNode Before-------------");
> > trace(targetNode.toXMLString());
> >
> >
> > //Replacing the Text of the node:
> > targetNode.setChildren("Replacement page content");
> >
>
> --
> View this message in context:
> http://www.nabble.com/Setting-text-on-a-text-node-in-e4x-tp20152621p20161963.html
>
> <http://www.nabble.com/Setting-text-on-a-text-node-in-e4x-tp20152621p20161963.html>
> Sent from the FlexCoders mailing list archive at Nabble.com.
>
>