Re: [flexcoders] Setting text on a text node in e4x

2008-10-25 Thread Mark Carter
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/ pageAbc/page page123/page pageXYZ/page

Re: [flexcoders] Setting text on a text node in e4x

2008-10-25 Thread Mark Carter
Thanks for that link Daniel - so, maybe I shouldnt be storing references to nodes/elements in the first place? Tamirin code - I wouldnt know where to start. Maybe if I forget about storing references in the first place, then I wouldnt need to... BTW - when I use FlexBuilder debugger to inspect

Re: [flexcoders] Setting text on a text node in e4x

2008-10-25 Thread Keith
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

Re: [flexcoders] Setting text on a text node in e4x

2008-10-25 Thread Mark Carter
Thanks - I do want to alter the original document, but keep the original text node. I.e. just change the text node's content. But its ok - I'm going to go with a different approach instead because it seems like a bad idea to hang on to references of text nodes... khair wrote: If you don't

[flexcoders] Setting text on a text node in e4x

2008-10-24 Thread Mark Carter
Hi - So, I know how to append a text node to an (parent) element, and how to replace a text node with a new text node (based on a specified string), but how do I set text on a text node? In my situation it is very important that the reference to the text node object is the same before and after

Re: [flexcoders] Setting text on a text node in e4x

2008-10-24 Thread Daniel Freiman
does this do it? parentElement.text()[index] = newText; - Daniel Freiman On Fri, Oct 24, 2008 at 11:48 AM, Mark Carter [EMAIL PROTECTED] wrote: Hi - So, I know how to append a text node to an (parent) element, and how to replace a text node with a new text node (based on a specified

RE: [flexcoders] Setting text on a text node in e4x

2008-10-24 Thread Tracy Spratt
To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Setting text on a text node in e4x does this do it? parentElement.text()[index] = newText; - Daniel Freiman On Fri, Oct 24, 2008 at 11:48 AM, Mark Carter [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi - So, I know how to append a text

Re: [flexcoders] Setting text on a text node in e4x

2008-10-24 Thread Mark Carter
Unfortunately not. I tried this: public static function setTextNodeText(textNode:XML, newText:String):void { var parentElement:XML = textNode.parent(); parentElement.*[textNode.childIndex()] = newText; } The textNode's parent is non-null before calling this method, but null after. Its

RE: [flexcoders] Setting text on a text node in e4x

2008-10-24 Thread Mark Carter
I should have mentioned that my elements have mixed content. Basically I have HTML (dynamically generated from some XML) in a TextArea. If some part of the text area is selected then I keep a reference to the corresponding text nodes (or subsets of text nodes), so that after the XML text has

Re: [flexcoders] Setting text on a text node in e4x

2008-10-24 Thread Daniel Freiman
Maybe it's not possible. At this point I'd go into the Tamirin code and see how it's handling xml text nodes. Another clue might be Alex's response to a question I asked a while ago: http://tech.groups.yahoo.com/group/flexcoders/message/114156 - Daniel Freiman On Fri, Oct 24, 2008 at 1:06 PM,

Re: [flexcoders] Setting text on a text node in e4x

2008-10-24 Thread Keith
Here's simple example on how to set the text value of node in AS3 Not sure if that what you're looking for as far as with the reference to the node: var doc= book toc/ toc/ pageAbc/page page123/page pageXYZ/page pageLast page/page index / index / /book; var