parsing multiple child with sax parser in Android
- by Ahmad Naqibul Arefin
I can parse xml file with sax parser, but when I need to add child attribute under a attribute then how I can get the value? my xml file is here:
<?xml version="1.0" encoding="UTF-8"?>
<marketlist>
<market>
<name restricted="yes">boss</name>
<motorway>M6</motorway>
<junction>J3</junction>
<petrol_hour>
<mon>7am - 8pm</mon>
<tues>7am - 8pm</tues>
</petrol_hour>
</market>
I want to parse and get mon and tues values. Any suggesstion? My android code for parsing is here:
public void endElement(String uri, String localName, String qName)
throws SAXException {
elementOn = false;
/**
* Sets the values after retrieving the values from the XML tags
* */
if (localName.equalsIgnoreCase("name"))
data.setMarketName(elementValue);
else if (localName.equalsIgnoreCase("motorway"))
data.setMotorway(elementValue);
else if (localName.equalsIgnoreCase("junction"))
data.setJunction(elementValue);