To replace the text of a node you can use replace();

var myXML:XML = <myRoot>blah</myRoot>;
trace("myXML:", myXML.toXMLString());

myXML.replace(0, "new node text");
trace("myXML:", myXML.toXMLString());

Output:

myXML: <myRoot>blah</myRoot>
myXML: <myRoot>new node text</myRoot>


-Michael


--- In flexcoders@yahoogroups.com, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Some success already, based on your suggestion:
>
> Any idea why the first option errors but the second succeeds?
>
> Option 1:
> var nodeTextNode:XML = _xmlNodeCurrent.text()[0];
> nodeTextNode = oEvent.target.text;      //ERRORS
>
> Option2:
> _xmlNodeCurrent.text()[0] = oEvent.target.text;      //succeeds.
>
> Tracy
>
> -----Original Message-----
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]
On Behalf Of Tracy Spratt
> Sent: Thursday, May 25, 2006 3:59 PM
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] Re: e4x XML Class: How to update a text node?
>
> That is not working for me.  I get an error "Type Coercion failed:
> cannot convert "new text node " to XML."  The text node currently has
> "new text node" in it and I am just adding a space character.
>
> What I am actually trying is more like this:
> var xmlCurrent:XML = xml.node[0];
> xmlCurrent = "textOne";
>
> I'll keep trying and post my progress.
>
> Tracy
>
> -----Original Message-----
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Geoffrey Williams
> Sent: Thursday, May 25, 2006 3:07 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: e4x XML Class: How to update a text node?
>
> var xml:XML = <root><node>text1</node><node>text2</node></root>;
> xml.node[0] = "textOne";
> xml.node[1] = "textTwo";
> trace (xml);
>
> --- In flexcoders@yahoogroups.com, "Tracy Spratt" <tspratt@>
> wrote:
> >
> > I can read, add and delete text nodes, but how can I update/modify
> one?
> >
> > Should I use replace()?  I think I can make that work and it seems
> > logical.
> >
> > Or delete and add?
> >
> > Or is there another way?
> >
> > Tracy
> >
>
>
>
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>

>
>
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to