parsing multiple child with sax parser in Android

Posted by Ahmad Naqibul Arefin on Stack Overflow See other posts from Stack Overflow or by Ahmad Naqibul Arefin
Published on 2012-10-10T03:34:12Z Indexed on 2012/10/10 3:36 UTC
Read the original article Hit count: 164

Filed under:
|
|

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);

© Stack Overflow or respective owner

Related posts about android

Related posts about Xml