Search code examples
xmlapache-flexactionscript-3

Accessing root node of XML in Flex


I'm having trouble accessing the value of the root node of an XML variable in flex.

For example:

var X:XML=
  <Message Type="abc">
    Content123
  </Message>

I can change the "Type" attribute above with X.@Type="xyz";

But how do I change "Content123" to something else?

If the xml document were longer/deeper, I could say something like X.Entry[11].Cost=2.22; But what do I say in this case? Obviously X="Content456" doesn't work...


Solution

  • This is one way to do it:

    var xml:XML=
      <Message Type="abc">
        Content123
      </Message>;
    
    xml.children()[0] = 'Content456';