In E4X, most common additions and modifications to an existing XML instance can be achieved using simple assignment statements. E4X assignments, however, have different results depending on the type of value being assigned and the target of the assignment. Let's look at the various scenarios one at a time.
To change the contents of an XML element, we assign that
element any value other than an XMLList or XML object. The value is converted to a
string and replaces the element's content. Recall our
var novel:XML = <BOOK ISBN="0141182806"> <TITLE>Ulysses</TITLE> <AUTHOR>Joyce, James</AUTHOR> <PUBLISHER>Penguin Books Ltd</PUBLISHER> </BOOK>
To change the contents of the
<TITLE> element from
Sun Also Rises", we use:
novel.TITLE = "The Sun Also Rises";
But remember that E4X lets us treat an XMLList like an XML object wherever possible, so because
the XMLList returned by
novel.TITLE has a single XML
instance only, we can use this more convenient code:
novel.TITLE = "The Sun Also Rises"; // Removed 
However, if the XMLList
novel.TITLE had more
the assignment would have a different meaning, as described in the
later section "Assigning Values to an XMLList."
(If you need a refresher on the difference between
novel.TITLE, see the earlier section,
"Treating XMLList as XML, Revisited.")
Now let's change the author and publisher of the ...