1

I have a XML file like this one:

<?xml version="1.0" encoding="UTF-8"?>
<training>
    <lesson name="Set_01">
        <exercise>
            <param controller="Training01"/>
            <param form="Training01"/>
            <param table="voctrain"/>
            <param subset="0,62"/>
            <param template="clicks"/>
            <param description="0101_0"/>
        </exercise>
        <exercise>
            <param controller="Training02"/>
            <param form="Training02"/>
            <param table="voctrain"/>
            <param subset="0,62"/>
            <param template="clicks"/>
            <param description="0101_1"/>
            <param sound="N"/>
            <param mode="DE"/>
            <param count="80"/>
        </exercise>
        <exercise>
            ...
        </exercise>
        <exercise>
        ...
        </exercise>
    </lesson>
    <lesson name="Set_02">
        <exercise>
        ...
        </exercise>
        <exercise>
        ...
        </exercise>
        <exercise>
        ...
        </exercise>
    </lesson>
</training>

With the XmlPullParser I can find the tags training and lesson, but for lesson I need the containing name. I want to collect all exercise parameters for a named lesson i.e. "Set_01". Within exercise there are some parameters like param count="80". Here I also need what is within param ... />. How to obtain it?

1

1 Answer 1

2

Try this code in your parser switch:

case XmlPullParser.END_TAG:
  String tag=parser.getName();
  if(tag.equals("lesson")){
     String name=parser.getAttributeValue(null,"name");
     ...
  }
Sign up to request clarification or add additional context in comments.

1 Comment

It can be so easy! Perfect answer! That's what I'm searching for.

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.