i am working with android and using xmlpullparser in android to parse an xml document that is like:

```
<spaces>
  <space>
    <name></name>
    <desc></desc>
    <songs>
      <song>
        <name></name>
        <thumb></thumb>
      </song>
      <song>
        <name></name>
        <thumb></thumb>
      </song>
    </songs>
  </space>
</spaces>

```

am using this:

```
public List<Space> parse(String xmlString) {
        List<Space> Spaces = null;
        XmlPullParser parser = Xml.newPullParser();
        try {
            parser.setInput(new StringReader(xmlString));
            int eventType = parser.getEventType();
            Space currentSpace = null;
            boolean done = false;
            while (eventType != XmlPullParser.END_DOCUMENT && !done) {
                String name = null;
                switch (eventType) {
                case XmlPullParser.START_DOCUMENT:
                    Spaces = new ArrayList<Space>();
                    break;
                case XmlPullParser.START_TAG:
                    name = parser.getName();
                    if (name.equalsIgnoreCase("space")) {
                        currentSpace = new Space();
                        System.out.println("space");

                    } else if (currentSpace != null) {

                        if (name.equalsIgnoreCase("name")) {
                            currentSpace.setName(parser.nextText());
                            System.out.println(":::"+currentSpace.getName());

                        } else if (name.equalsIgnoreCase("id")) {
                            if (currentSpace.getId() == null) {
                                currentSpace.setId(parser.nextText());
                            }

                        }

                    }

                    break;
                case XmlPullParser.END_TAG:
                    name = parser.getName();
                    if (name.equalsIgnoreCase("space") && currentSpace != null) {
                        Spaces.add(currentSpace);

                    } else if (name.equalsIgnoreCase("spaces")) {
                        done = true;

                    }
                    break;
                }
                eventType = parser.next();  
            }
        } catch (Exception e) {
            Log.e("Projects List", e.getMessage(), e);
            throw new RuntimeException(e);
        }
        return Spaces;
    }

```

My problem is i want only `<name></name>` which is in `<space>` not within `<song>` and using above code am getting both.

i looked [Parsing XML XmlPullParser android](https://stackoverflow.com/questions/7291886/parsing-xml-xmlpullparser-android) but dint get my solution.

Please Reply.
Thanks.