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

  • SEARCH
  • Home
  • 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 7888447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:50:02+00:00 2026-06-03T05:50:02+00:00

i parse the xml file and all data will parsed but i dont understand

  • 0

i parse the xml file and all data will parsed but i dont understand how to set this data in textview ? give me some idea about that

    public class GtuItemXMLHandler extends DefaultHandler {

    Gtudownload gtudownload;
    Questionpaper questionpaper;

    // Show me the XML.
    private String currentString = "";
    private String charactersString = "";
    private Branch branch;
    private Year year;
    private Semester semester;
    private int branchCount = 0;
    private int yearCount = 0;
    private int semesterCount = 0;

//  private ArrayList<Gtudownload> itemsList = new ArrayList<Gtudownload>();
//  
//  public ArrayList<Gtudownload> getItemsList() {
//      return itemsList;
//  }

    public Gtudownload getGtudownload(){
        return this.gtudownload;
    }
    public Questionpaper getQuestionpaper()
    {
        return this.questionpaper;
    }


    // Called when tag starts
    @Override
    public void startElement(String uri, String localName, String qName,
            Attributes attributes) throws SAXException {
        Log.i("GTU ", localName);
        if (localName.equalsIgnoreCase("Gtudownload")) {
            gtudownload = new Gtudownload();
            currentString = "Gtudownload";

        } else if (localName.equalsIgnoreCase("Questionpaper")) {
            gtudownload.setQuestionpaper(new Questionpaper());
            gtudownload.getQuestionpaper().setBranchList(new ArrayList<Branch>());
            currentString = "Questionpaper";
        } else if (localName.equalsIgnoreCase("Branch")) {
            branch = new Branch();
            gtudownload.getQuestionpaper().getBranchList().add(branch);
            gtudownload.getQuestionpaper().getBranchList().get(branchCount).setYearList(new ArrayList<Year>());
            currentString = "Branch";
            Log.i("Branch", attributes.getValue("value"));
            branch.setValue(attributes.getValue("value"));
        } else if (localName.equalsIgnoreCase("Year")) {
            year = new Year();
            gtudownload.getQuestionpaper().getBranchList().get(branchCount).getYearList().add(year);
            gtudownload.getQuestionpaper().getBranchList().get(branchCount).getYearList().get(yearCount).setSemesterList(new ArrayList<Semester>());
            currentString = "Year";
            Log.i("Year ", attributes.getValue("value"));
            year.setValue(attributes.getValue("value"));
        } else if (localName.equalsIgnoreCase("semester")) {
            semester = new Semester();          
            currentString = "semester";
            Log.i("Semester ", attributes.getValue("value"));
            semester.setValue(attributes.getValue("value"));
            gtudownload.getQuestionpaper().getBranchList().get(branchCount).getYearList().get(yearCount).getSemesterList().add(semester);
        } else if (localName.equalsIgnoreCase("url")){ 
            currentString = "url";
        }

    }

    // Called when tag closing
    @Override
    public void endElement(String uri, String localName, String qName)
            throws SAXException {
        if(localName.equalsIgnoreCase("Questionpaper")){
            branchCount=0;           
        }else if(localName.equalsIgnoreCase("Branch")){
            yearCount = 0;
            branchCount++;
        }else if(localName.equalsIgnoreCase("Year")){
            semesterCount = 0;
            yearCount++; 
        }else if(localName.equalsIgnoreCase("semester")){
            semesterCount++;
        }else if(localName.equalsIgnoreCase("url")){
            gtudownload.getQuestionpaper().getBranchList().get(branchCount).getYearList().get(yearCount).getSemesterList().get(semesterCount).setUrl(charactersString);
            Log.i("URL", charactersString);
        }
        currentString = "";
        charactersString= "";

    }

    // Called to get tag characters
    @Override
    public void characters(char[] ch, int start, int length)
            throws SAXException {
        charactersString = new String(ch, start, length);
        charactersString = charactersString.trim();
    }

}

this is my activity and how can i set this parsing data in into textview

    public class GtudldActivity extends Activity {
    /** Called when the activity is first created. */
    private TextView xmlOutput;
    TextView example[];

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        xmlOutput = (TextView) findViewById(R.id.xmlOutput);

        Gtudownload gtudownload = parseXML();

    }

    private Gtudownload parseXML() {

        Gtudownload gtudownload = null;

        try {

            Log.w("AndroidParseXMLActivity", "Start");
            /** Handling XML */
            SAXParserFactory spf = SAXParserFactory.newInstance(); 
            SAXParser sp = spf.newSAXParser();       
            XMLReader xr = sp.getXMLReader(); 

            GtuItemXMLHandler myXMLHandler = new GtuItemXMLHandler();
            xr.setContentHandler(myXMLHandler);
            InputSource is = new InputSource(getResources().openRawResource(R.raw.mgtu));


            gtudownload = myXMLHandler.getGtudownload();

            Log.i("Data",gtudownload+"");
            xr.parse(is);

        } catch (Exception e) {
            Log.w("AndroidParseXMLActivity", e);
        }

        //xmlOutput.setText(gtudownload.toString());

        return gtudownload;

    }
}
  • 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-06-03T05:50:03+00:00Added an answer on June 3, 2026 at 5:50 am

    You’ll get so many examples for this on google. I am showing you one of the. Just try this

    I hope it may help you. If you’ve any doubt, just post it here

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

Sidebar

Related Questions

I am trying to parse this xml file, which has some nested nodes. I
I use nokogiri(which in turn uses xpath) to parse xml file. xml has some
I have written a small function, which uses ElementTree to parse xml file,but it
When I parse my xml file (variable f) in this method, I get an
Basically I have an XML file that looks like this: <?xml version=1.0 encoding=UTF-8?> <data>
I am making a program that will store its data in an XML file.
I have 2 questions: 1-I need to parse XML file and insert the data
So I have 0.5MB XML file with data for my iPhone application. It's all
Today I needed to parse some data out from an xlsx file (Office open
I need to parse an XLIFF file using C#, but I'm having some trouble.

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.