ActionScript E4X 获取标签属性

发布于 2024-11-04 03:50:57 字数 251 浏览 4 评论 0原文

对于 E4X,我是一个真正的新手,所以请耐心等待。我正在开发一个 ActionScript 3.0 项目,我想从 XML 标记中提取所有属性。

我使用了 XML.attributes() 方法,但只返回每个属性的/我希望获取所有属性名称 给定 XML 标记的属性值。

有人可以告诉我如何获得这个吗?

谢谢您的宝贵时间,
斯普里诺724

I am a real newbie when it comes to E4X, so please bear with me. I am working on an ActionScript 3.0 project which I would like to extract all of the attributes from an XML tag.

I have used the XML.attributes() method, but that only returns the value of each attribute/ I would like the to get all of the attribute names and attribute values for a given XML tag.

Could someone please show me as to how I could obtain this?

Thank you for your time,
spryno724

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

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

发布评论

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

评论(2

晒暮凉 2024-11-11 03:50:58

Google 是你的朋友

var xml:XML = <example id='123' color='blue'/>
var attNamesList:XMLList = xml.@*;

trace (attNamesList is XMLList); // true
trace (attNamesList.length()); // 2

for (var i:int = 0; i < attNamesList.length(); i++)
{ 
    trace (typeof (attNamesList[i])); // xml
    trace (attNamesList[i].nodeKind()); // attribute
    trace (attNamesList[i].name()); // id and color
} 

Google is your friend

var xml:XML = <example id='123' color='blue'/>
var attNamesList:XMLList = xml.@*;

trace (attNamesList is XMLList); // true
trace (attNamesList.length()); // 2

for (var i:int = 0; i < attNamesList.length(); i++)
{ 
    trace (typeof (attNamesList[i])); // xml
    trace (attNamesList[i].nodeKind()); // attribute
    trace (attNamesList[i].name()); // id and color
} 
初熏 2024-11-11 03:50:58

XML.attributes() 不仅返回值,您还只是看到属性的字符串序列化。给定 attr =.attributes()[0]attr.localname() === "bar"attr.toString() === "baz"

XML.attributes() doesn't only return the value, you're just seeing the string serialization of the attributes. Given attr = <foo bar="baz"/>.attributes()[0], attr.localname() === "bar" and attr.toString() === "baz".

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