You need an XML parser. There are several APIs that you can use to parse an XML document. StAX may be the easiest one to get you going, but it's only in JDK 6.0/JAXP 1.4. Here is a link to the reader class:
http://java.sun.com/javase/6/docs/api/javax/xml/stream/XMLStreamReader.html
Otherwise, search for documentation on SAX or DOM. Hope this helps.