在 AS3 中使用 E4X 在 XML 节点中创建新属性

发布于 2024-07-14 23:06:15 字数 18 浏览 10 评论 0原文

有什么办法可以做到吗?

Is there any way to do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

紫罗兰の梦幻 2024-07-21 23:06:15

谢谢回答。

我确实发现您的解释和链接建议有趣且令人鼓舞。

无论如何,我没有把我的问题说清楚。 我确实想知道的是如何创建任何属性,即使不知道它的名称。 我确实阅读了一些文档和教程,直到我弄清楚为止。 希望这能有所帮助。

var data:XML = <node/>;
var $my_attr:String = 'id';
data.@[$my_attr] = 'foo';

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';
赠我空喜 2024-07-21 23:06:15

要添加属性,您需要写为

xmlNode.attributes.@attr = "值";

希望它有效。

谢谢
阿米特

To add attribute you need to write as

xmlNode.attributes.@attr = "value";

Hope it works.

Thx
Amitd

箹锭⒈辈孓 2024-07-21 23:06:15

长答案:请阅读文档。 确实是非常丰富了。 整章都专门讨论 XML 和 E4X。 这里的链接可能会有所帮助给你。

简短回答:是的。

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.

不离久伴 2024-07-21 23:06:15

dirkgently 没有直接告诉你怎么做,我想是出于教育目的。 尽管如此,方法如下:

var xml:XML = <node/>;
xml.@attr = "value";

Tada! 但是拜托,RTFM。

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.

慕巷 2024-07-21 23:06:15

xmlNode.attributes['属性'] = '属性值';

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文