Как получить все атрибуты, которые существуют на узле XML? Например, у меня есть следующий XML:
<item id="100">
<defaults width="10" height="100" post="true">
</item>
Я хотел бы получить имена и значения на узле по умолчанию.
Вот некоторый стартовый код:
if (item.defaults) {
var attributes:Object = item.defaults.@*; // found in another post
for each (var value:String in attributes) {
trace("value "+value); // prints 10,100,true
}
for (var property:String in attributes) {
trace("property "+property); // prints 0,1,2 - I need to know the names
}
}
Я нашел ответ:
if (item.defaults) {
attributes = item.defaults.attributes();
attributesLength = attributes.length();
defaults = {};
for each (var attribute:Object in attributes) {
propertyName = String(attribute.name());
defaults[propertyName] = String(attribute);
}
}