2

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?

1 Answer 1

1

I believe you'd reference the parent with an index, so in your case it would be

_______.display.service.LayerGroups.fields.field[0].attribute,

for the first one, and

_______.display.service.LayerGroups.fields.field[1].attribute,

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.