I'm having trouble accessing the value of the root node of an XML variable in flex.
For example:
var X:XML=
<Mes开发者_如何学Csage 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...
This is another way, a little safer because you explicitly assign the new value to a text node:
var xml:XML=
<Message Type="abc">
Content123
</Message>;
xml.text()[0] = 'Content456';
This is one way to do it:
var xml:XML=
<Message Type="abc">
Content123
</Message>;
xml.children()[0] = 'Content456';
If it doesn't have any other child element, you can do X.setChildren("something else");
to achieve this.
x.Message would give the value "abc" in your case.. so u can change it easily i guess!
精彩评论