E4X : Assigning to root node

Question :

E4X : Assigning to root node,

Answer :

I am using Adobe Flex/Air here, but as far as I know this applies to all of JavaScript. I have come across this problem a few times, and there must be an easy solution out there!

Suppose I have the following XML (using e4x):

var xml:XML = foo  

I can change the contents of the example node using the following code:

xml.example = "bar";  

However, if I have this:

var xml:XML = foo  

How do i change the contents of the root node?

xml = "bar";  

Obviously doesn’t work as I’m attempting to assign a string to an XML object.

Read More  Anyone know of an on-line free database?


It seems you confuse variables for the values they contain. The assignment

node = textInput.text;  

changes the value the variable node points to, it doesn’t change anything with the object that node currently points to. To do what you want to do you can use the setChildren method of the XML class:


That’s the answer E4X : Assigning to root node, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Read More  Add .NET 2.0 SP1 as a prerequisite for deployment project

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you