I have an xml file with a structure like this
<display>
<service>
<URL></URL>
<name></name>
<LayerGroups>
<id></id>
<fields>
<field>
<attribute>object</attribute>
<alias>OBJECT</alias>
</field>
<field>
<attribute>name</attribute>
<alias>NAME</alias>
</field>
<fields>
</LayerGroup>
</service>
</display>
I would like to know how I can reference each individual attribute. I imagine it would be something along the lines of _______.display.service.LayerGroups.fields.field.attribute, but there are two “field” and two “attribute”. How do I make the distinction?
I believe you’d reference the parent with an index, so in your case it would be
for the first one, and
for the second one.
When accessing XML, if there are more than one tags of the same name, you’d use an index at the end of the tag within action script. The first in a collection of tags with the same name would be [0], incrementing by one for each subsequent tag with that name. This is assuming that all tags are on the same level within the XML document structure.
See this