Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6181855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:06:02+00:00 2026-05-24T01:06:02+00:00

EveryOne I am doing xml parsing like This public class XMLHandler extends DefaultHandler{ //

  • 0

EveryOne I am doing xml parsing like This

public class XMLHandler extends DefaultHandler{

 // ===========================================================
 // Fields
 // ===========================================================
static ArrayList<Category1> cat_list=new ArrayList<Category1>();
static ArrayList<Products> product_list=new ArrayList<Products>();
   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 & 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:
  * <tag>
  * Can provide attribute(s), when xml was like:
  * <tag attribute="attributeValue">*/
 @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:
  * </tag> */
 @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:
  * <tag>characters</tag> */
 @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);
     }
}

}

I parse all thing very good but not url….

The Xml file is like this

<?xml version="1.0" encoding="UTF-16"?>
<products>

    <product catid="11">

        <name>song1</name>

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

    </product>

I got the result ned=en_il only

Please Help me, Where i am wrong??
Thankx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:06:03+00:00Added an answer on May 24, 2026 at 1:06 am

    You may try by warping your <url> node into CDATA tag like this

    <url><![CDATA[http://news.google.co.in/news?edchanged=1&ned=en_il]]></url>
    

    to rectify the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi everyone I am trying to make a camera app. I am doing this
Everyone has this huge massively parallelized supercomputer on their desktop in the form of
Everyone is familiar with this functionality. If you open up the the outlook address
Everyone uses source-code control to manage versions (right?) and this provides some level of
Hope everyone here are doing great! Here is a situation where I need to
Everyone remembers google browser sync right? I thought it was great. Unfortunately Google decided
Everyone I work with is obsessed with the data-centric approach to enterprise development and
Everyone has accidentally forgotten the WHERE clause on a DELETE query and blasted some
Everyone (at least everyone who uses a compiled language) has faced compilation errors but
Everyone managing open-source-software runs into the problem, that with the time the process of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.