# Accessing an Attribute

**URL:** <https://forum.kirupa.com/t/accessing-an-attribute/274656>\
**Category:** flash\
**Created:** [November 2, 2008, 6:19am UTC](https://forum.kirupa.com/t/accessing-an-attribute/274656 "2008-11-02T06:19:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pherank](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pherank](https://forum.kirupa.com/u/Pherank)\
**Post date:** [November 2, 2008, 6:19am UTC](https://forum.kirupa.com/t/accessing-an-attribute/274656/1 "2008-11-02T06:19:59Z")

</div>

I have some XML that is structured like this:

```auto

<quiz>

    <item category="Health">
        <question>Can you override medication orders?</question>
        <answers>
            <answer>First answer</answer>
            <answer>Second answer</answer>
            <answer>Third answer</answer>
            <answer status="correct">Fourth anser</answer>
        </answers>
        <correctFeedback><b>That's correct!</b></correctFeedback>
        <incorrectFeedback><b>Incorrect.</incorrectFeedback>
    </item>

</quiz>

```

This is part of a multiple choice quiz. The correct answer was originally set to be the first item listed, but I want to change that so that the correct answer is determined by the “answer” node with an attribute “status” set to “correct”:

```auto

correctAnswer = dataXML.item[questionNum].answers.answer[0];
//correctAnswer = dataXML.item[questionNum].answers.answer.*.(@status == "correct");
//trace(dataXML.item[questionNum].answers.answer.attribute("correct"));
//trace(dataXML.item[questionNum].answers.answer.(@status=="correct"));
answers = shuffleAnswers(dataXML.item[questionNum].answers);

```

I’ve tried various things but I either get empty output (I assume that means null), or I get ReferenceError: Error #1065: Variable @status is not defined. Can anyone tell me what the correct syntax would be?

(Note that tracing correctAnswer = dataXML.item[questionNum].answers.answer[0]; gives the node value of the first answer node)
