tags:

views:

27

answers:

1

Hi BB developers I have a issue while parsing the xml data using DOM. The xml data format is:

<stimulus name="Question" type="0">
<card>
<no>1</no>
<text><![CDATA[What is your primary goal, challenge or problem?]]></text>
</card>-----------------------
<stimulus name="Noun" type="0">
<card>
<no>12</no>
<text><![CDATA[Evaluation Criteria]]></text>
</card>

The following code snippet is used to parse the data

    NodeList nl = element.getElementsByTagName("stimulus");

    if (nl != null && nl.getLength() > 0) {
        for (int i = 0; i < nl.getLength(); i++) {
            Element ele = (Element) nl.item(i);
            Data card = getQuestions(ele);
            dataList.addElement(card);
        }
    }

When I parse the data by using root tag "stimulus" I don't get the data sequentially. I need to parse the data sequentially. Where did I make a mistake?

+1  A: 

It looks like the <stimulus> elements are not closed in your source document, which may be causing problems in the parser. Try adding a </stimulus> to end each group.

Michael Donohue
Yes you are right. It is working now.
Koushik