Is there any way to do it?
Asked
Active
Viewed 1.2k times
5 Answers
10
Thanks for answering.
I did found your explanations and link suggestions interesting and encouraging.
Anyway, I did not make myself clear with my question. What I did want to know was how to create any property, even without knowing it's name. I did read several docs and tutorials until I figured it out. Hope this can be of help.
var data:XML = <node/>;
var $my_attr:String = 'id';
data.@[$my_attr] = 'foo';

TurboHz
- 2,146
- 2
- 16
- 14
-
Ah, now that's a different issue. I beleive data['@' + attrName] should also do the trick. – David Hanak Mar 17 '09 at 12:54
1
To add attribute you need to write as
xmlNode.attributes.@attr = "value";
Hope it works.
Thx Amitd
0
Long answer: Please do read the documentation. It is indeed very rich. Entire chapters have been devoted to XML and E4X. Here's a link that may be helpful to you.
Short answer: Yes.

dirkgently
- 108,024
- 16
- 131
- 187
0
dirkgently didn't directly tell you how to do it, I guess with an educational purpose. Nonetheless, here's how:
var xml:XML = <node/>;
xml.@attr = "value";
Tada! But please, RTFM.

David Hanak
- 10,754
- 3
- 31
- 39
-
@ turboHz I agree with David, It's really not good practice, for your own skills I mean, to not give it a shot yourself first and do at least a basic search in the documentation or on google. – BefittingTheorem Mar 14 '09 at 11:26