user77838
user77838

Reputation:

Creating a new attribute in an XML node using E4X in AS3

Is there any way to do it?

Upvotes: 4

Views: 11618

Answers (5)

user77838
user77838

Reputation:

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';

Upvotes: 10

jcx
jcx

Reputation: 1

xmlNode.attributes['attribute'] = 'attribute value';

Upvotes: 0

Amit Dhamal
Amit Dhamal

Reputation:

To add attribute you need to write as

xmlNode.attributes.@attr = "value";

Hope it works.

Thx Amitd

Upvotes: 1

David Hanak
David Hanak

Reputation: 10984

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.

Upvotes: 0

dirkgently
dirkgently

Reputation: 111210

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.

Upvotes: 0

Related Questions