Trouble parsing self closing XML tags using SAX parser
- by sandesh
Hi,
I am having trouble parsing self closing XML tags using SAX. I am trying to extract the link tag from the Google Base API.I am having reasonable success in parsing regular tags.
Here is a snippet of the xml
<entry>
<id>http://www.google.com/base/feeds/snippets/15802191394735287303</id>
<published>2010-04-05T11:00:00.000Z</published>
<updated>2010-04-24T19:00:07.000Z</updated>
<category scheme='http://base.google.com/categories/itemtypes' term='Products'/>
<title type='text'>En-el1 Li-ion Battery+charger For Nikon Digital Camera</title>
<link rel='alternate' type='text/html' href='http://rover.ebay.com/rover/1/711-67261-24966-0/2?ipn=psmain&icep_vectorid=263602&kwid=1&mtid=691&crlp=1_263602&icep_item_id=170468125748&itemid=170468125748'/>
.
.
and so on
I can parse the updates and published tags, but not the link and category tag.
Here is my startElement and endElement overrides
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
if (qName.equals("title") && xmlTags.peek().equals("entry")) {
insideEntryTitle = true;
}
xmlTags.push(qName);
}
public void endElement(String uri, String localName, String qName)
throws SAXException {
// If a "title" element is closed, we start a new line, to prepare
// printing the new title.
xmlTags.pop();
if (insideEntryTitle) {
insideEntryTitle = false;
System.out.println();
}
}
declaration for xmltags..
private Stack<String> xmlTags = new Stack<String>();
Any help guys?
this is my first post here.. I hope I have followed posting rules! thanks a ton guys..