Use this link for SAX parser
And also see the difference b/w sax and dom diffrence
Just use this parser to parse your xml
public class EmployeeParser extends DefaultHandler {
private StringBuilder responseTag;
private List<Album> listAblum = new ArrayList<Album>();
private Album album;
@Override
public void startDocument() throws SAXException {
super.startDocument();
listAblum.clear();
}
@Override
public void endDocument() throws SAXException {
super.endDocument();
}
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
super.startElement(uri, localName, qName, attributes);
responseTag = new StringBuilder();
if (localName.equals("album")) {
album = new Album();
album.setAlbumValue(attributes.getValue("value"));
} else if ("imageid".equals(localName)) {
album.setDetails(attributes.getValue("value"));
} else if ("songs".equals(localName)) {
album.setSongs(attributes.getValue("value"));
}
}
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
super.endElement(uri, localName, qName);
if (localName.equals("album")) {
listAblum.add(album);
} else if ("lyrics".equals(localName)) {
album.setLyrics(responseTag.toString());
}
}
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
super.characters(ch, start, length);
String str = new String(ch, start, length);
responseTag.append(str);
}
class Album {
private String songs, imageId, lyrics, albumValue, details;
public String getSongs() {
return songs;
}
public void setSongs(String songs) {
this.songs = songs;
}
public String getImageId() {
return imageId;
}
public void setImageId(String imageId) {
this.imageId = imageId;
}
public String getLyrics() {
return lyrics;
}
public void setLyrics(String lyrics) {
this.lyrics = lyrics;
}
public String getAlbumValue() {
return albumValue;
}
public void setAlbumValue(String albumValue) {
this.albumValue = albumValue;
}
public String getDetails() {
return details;
}
public void setDetails(String details) {
this.details = details;
}
}
}