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 8757953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:25:33+00:00 2026-06-13T14:25:33+00:00

i have problem concerning to XML and java.util.List. In my script Iam able to

  • 0

i have problem concerning to XML and java.util.List. In my script Iam able to parse XML file from input and System writes me e.g. [124, 123], [123, 130] (according to this what is in the input file.) but my question is – how to pass values from xList and yList to paint method? What do I Have to do? set/get value? Or maybe is there a better way how to do it. Thanks

part of my script:

    try
        {

        SAXParserFactory factory = SAXParserFactory.newInstance();
        SAXParser saxParser = factory.newSAXParser();

        MyDefaultHandler handler = new MyDefaultHandler();
        saxParser.parse(filechooser.getSelectedFile(), handler);
        System.out.println(handler.getXList() + ", " + handler.getYList());
    }
    catch (Exception exe)
    {
        exe.printStackTrace();
    }
    }    
        }

    class MyDefaultHandler extends DefaultHandler
{
    final List<Integer> xList = new ArrayList<Integer>();
    final List<Integer> yList = new ArrayList<Integer>();

    boolean xele = false;
    boolean yele = false;

    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
    {

        if (qName.equalsIgnoreCase("X"))
        {
            xele = true;
        }

        if (qName.equalsIgnoreCase("Y"))
        {
            yele = true;
        }


    }

    public void characters(char ch[], int start, int length) throws SAXException
    {

        if (xele)
        {
            System.out.println("X value : " + new String(ch, start, length));
            xele = false;
            xList.add(Integer.parseInt(new String(ch, start, length)));
        }

        if (yele)
        {
            System.out.println("Y value : " + new String(ch, start, length));
            yele = false;
            yList.add(Integer.parseInt(new String(ch, start, length)));

        }
;
    }

    final List<Integer> getXList()
    {
        return xList;

    }

    final List<Integer> getYList()
    {
        return yList;
    }
  • 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-13T14:25:35+00:00Added an answer on June 13, 2026 at 2:25 pm

    If I understand you question and expecting that the lists are of the same length, you’ll need something like this:

    for (int i=0; i<xList.size(); i++) { paint(xList.get(i),yList.get(i)); } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a problem concerning android layouts. In my xml file I have two
I have a problem concerning a HashMap in Java. To explain the problem in
I have created a sample query in sql server to parse data from xml
I am currently converting an xml file to java coding, but I have met
I have a problem. I have an XML spreadsheet file that I'm trying to
I have a question concerning XML, Java's use of DOM, and empty nodes. I
I have problem concerning python packages and testing. I'm writing an application using wx
I have a problem concerning the width of a DialogPreference in Android. According to
i have a problem concerning a select query in MYSQL i have two different
I am using LaTeX and I have a problem concerning string manipulation. I want

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.