I’m using SAX parsing in android. For below XML:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Game Analysis</title>
<item>
<title>GTA</title>
<description>ABC</description>
<pubDate>Sat, 21 Feb 2012 05:18:23 GMT</pubDate>
<enclosure type="audio/mpeg" url="http://URL.mp3" length="6670315"/>
</item>
<item>
<title>CoD</title>
<description>XYZ</description>
<pubDate>Sat, 21 Feb 2011 05:18:23 GMT</pubDate>
<enclosure type="audio/mpeg" url="http://URL.mp3" length="6670315"/>
</item>
</channel>
</rss>
I need to fetch the first occurance of <title> (just below ).
Then from every block I again need to extract <title> & <enclosure>.
I can fetch the first <title> using:
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
if (qName.equals(“title”))
…
}
But, how should I fetch the tags inside <item> block?
Here is how I’ve done that with SAX.
I have modified a bite your XML file.
XML file
Entities
Channel
Enclosure
Item
Handler
ChannelHandler
Manager
XMLManager
The main
MyMain
Output in the console
So it works 😉