Xml Parsing in android
<p>EveryOne I am doing xml parsing like This</p>

<pre><code>public class XMLHandler extends DefaultHandler{

 // ===========================================================
 // Fields
 // ===========================================================
static ArrayList&lt;Category1&gt; cat_list=new ArrayList&lt;Category1&gt;();
static ArrayList&lt;Products&gt; product_list=new ArrayList&lt;Products&gt;();
   Category1 cat;
   Products pro;
 private boolean in_outertag = false;
 private boolean in_innertag = false;
 private boolean in_mytag = false;
 private boolean in_mytag1 = false;
 private boolean in_mytag2 = false;
 private boolean in_mytag3 = false;


 private XMLDataSet myParsedExampleDataSet = new XMLDataSet();

 // ===========================================================
 // Getter &amp; Setter
 // ===========================================================

 public XMLDataSet getParsedData() {
      return this.myParsedExampleDataSet;
 }

 // ===========================================================
 // Methods
 // ===========================================================
 @Override
 public void startDocument() throws SAXException {
      this.myParsedExampleDataSet = new XMLDataSet();
 }

 @Override
 public void endDocument() throws SAXException {
      // Nothing to do
 }

 /** Gets be called on opening tags like:
  * &lt;tag&gt;
  * Can provide attribute(s), when xml was like:
  * &lt;tag attribute="attributeValue"&gt;*/
 @Override
 public void startElement(String namespaceURI, String localName,
           String qName, Attributes atts) throws SAXException {
      if (localName.equals("root")) {
           this.in_outertag = true;
      }else if (localName.equals("Categories")) {
           this.in_innertag = true;
      }else if (localName.equals("Category")) {
          cat =new Category1();
          String attrValue = atts.getValue("id");
          int i = Integer.parseInt(attrValue);
          myParsedExampleDataSet.setExtractedInt(i);
          cat.setCatId(i+"");
          //cat_id[i]=myParsedExampleDataSet.setExtractedInt(i);
          //Log.i("id", cat.setCatId(i+""));
          String attrValue1 = atts.getValue("pid");
          int i1 = Integer.parseInt(attrValue1);
          myParsedExampleDataSet.setExtractedInt(i1);
          cat.setPid(i1+"");
          //p_id[i1]=myParsedExampleDataSet.setExtractedInt(i1);
          //Log.i("pid", myParsedExampleDataSet.setExtractedInt(i1)+"");
           this.in_mytag = true;
      }else if (localName.equals("title")) {
           // Extract an Attribute

          this.in_mytag1 = true;
      }else if (localName.equals("products")) {
           this.in_innertag = true;
      }else if (localName.equals("product")) {
          pro=new Products();
          String attrValue = atts.getValue("catid");
          int i = Integer.parseInt(attrValue);
          myParsedExampleDataSet.setExtractedInt(i);
          pro.setCatId(i+"");
          //Log.i("catid", myParsedExampleDataSet.setExtractedInt(i)+"");
           this.in_mytag = true;
      }else if (localName.equals("name")) {
           // Extract an Attribute
          this.in_mytag2 = true;
      }else if (localName.equalsIgnoreCase("url")) {
           // Extract an Attribute
          this.in_mytag3 = true;
      }
 }

 /** Gets be called on closing tags like:
  * &lt;/tag&gt; */
 @Override
 public void endElement(String namespaceURI, String localName, String qName)
           throws SAXException {
      if (localName.equals("root")) {
           this.in_outertag = false;
      }else if (localName.equals("Categories")) {
           this.in_innertag = false;
      }else if (localName.equals("Category")) {
          cat_list.add(cat);

           this.in_mytag = false;
      }else if (localName.equals("title")) {

           this.in_mytag1=false;
      }else if (localName.equals("products")) {

          this.in_innertag=false;
     }else if (localName.equals("product")) {
      product_list.add(pro);
         this.in_mytag=false;
    }else if (localName.equals("name")) {

        this.in_mytag2=false;
   }else if (localName.equalsIgnoreCase("url")) {

       this.in_mytag3=false;
  }
 }

 /** Gets be called on the following structure:
  * &lt;tag&gt;characters&lt;/tag&gt; */
 @Override
public void characters(char ch[], int start, int length) {
      if(this.in_mytag1){
      myParsedExampleDataSet.setExtractedString(new String(ch, start, length));
      cat.setCatName(new String(ch, start, length));
 }
      if(this.in_mytag2){
          myParsedExampleDataSet.setExtractedString(new String(ch, start, length));
          pro.setProductId(new String(ch, start, length));
     }
      if(this.in_mytag3){
          String chars = new String(ch, start, length); 
            chars = chars.trim(); 
          //myParsedExampleDataSet.setExtractedString(chars);
          pro.setUrl(chars);
     }
}
</code></pre>

<p>}</p>

<p>I parse all thing very good but not url....</p>

<p>The Xml file is like this  </p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-16"?&gt;
&lt;products&gt;

    &lt;product catid="11"&gt;

        &lt;name&gt;song1&lt;/name&gt;

        &lt;url&gt;http://news.google.co.in/news?edchanged=1&amp;amp;ned=en_il&lt;/url&gt;

    &lt;/product&gt;
</code></pre>

<p></p>

<p>I got the result <code>ned=en_il</code> only</p>

<p>Please Help me, Where i am wrong??
Thankx </p>
