I have already written a handler class. And it seems working. Here is the java source. thanks for help. It was not so hard
import java.util.ArrayList;
import java.util.HashMap;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class MuyapHandler extends DefaultHandler {
private String item = null ;
private String performerId = null ;
private HashMap performerMap = new HashMap() ;
private ArrayList songList = new ArrayList() ;
private String[] values = null ;
private int index = -1 ;
public void startDocument() throws SAXException {
performerMap = new HashMap() ;
songList = new ArrayList() ;
item = null ;
performerId = null ;
values = null ;
index = -1 ;
}
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equals("song")) {
String songID = attributes.getValue("songID") ;
values = new String[5] ;
values[0] = songID ;
} else if (qName.equals("songName")) {
item = "songName" ;
index = 1 ;
} else if (qName.equals("songPerformerID")) {
item = "songPerformerID" ;
index = 2 ;
} else if (qName.equals("producer")) {
item = "producer" ;
index = 3 ;
} else if (qName.equals("label")) {
item = "label" ;
index = 4 ;
} else if (qName.equals("performerDisplay")) {
performerId = attributes.getValue("performerDisplayID") ;
}
super.startElement(uri, localName, qName, attributes);
}
public void endElement(String uri, String localName, String qName) throws SAXException {
if (qName.equals("song")) {
songList.add(values) ;
}
super.endElement(uri, localName, qName) ;
}
public void characters(char[] ch, int start, int length) throws SAXException {
if (item != null) {
if (item.equals("songPerformerID")) {
values[index] = (String) performerMap.get(new String(ch, start, length)) ;
} else {
values[index] = new String(ch, start, length) ;
}
item = null ;
} else if (performerId != null) {
String performerName = new String(ch, start, length) ;
performerMap.put(performerId, performerName) ;
performerId = null ;
}
}
public ArrayList getSongList() {
return songList;
}
}