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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:13:27+00:00 2026-05-21T09:13:27+00:00

I have two sax parser as follows: try { SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); SAXParser

  • 0

I have two sax parser as follows:

 try {
                SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
                SAXParser parser1 = SAXParserFactory.newInstance().newSAXParser();


                parser.parse(new File("G:\\Documents\\posts.xml"), this);
                parser1.parse(new File("G:\\Documents\\comments.xml"), this);
            } catch (Exception ex) {
                ex.printStackTrace();
            }

the question is that when the handler startElement is called, how do I check whether this is from parser1 or parser2? I am assuming that uri and localName is used, but how?

  • 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-21T09:13:28+00:00Added an answer on May 21, 2026 at 9:13 am

    I’d suggest using two handlers. As a trivial example (you’ll have to fill in the details):

    class SaxClass {
       Handler h1;
       Handler h2;
    
       //...stuff
    
       method() {
          h1 = new Handler();
          h2 = new Handler();
    
          try {
             SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
             SAXParser parser1 = SAXParserFactory.newInstance().newSAXParser();
    
             parser.parse(new File("G:\\Documents\\posts.xml"), h1);
             parser1.parse(new File("G:\\Documents\\comments.xml"), h2);
          } catch (Exception ex) {
             ex.printStackTrace();
          }
       }
    
       class Handler extends DefaultHandler {
          // Implementation
       }
    }
    

    It doesn’t look like there’s a way to find the parser that generated the event.

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

Sidebar

Related Questions

I don't get it. I have two activities in which i parse an XML-file
Possible Duplicate: JAVA SAX parser split calls to characters() I have an XML file
I have an XML file that I am trying to parse with Sax (this
I have two files client.php and server.php. The client file send a HTTP request
Have two IBOutlets which won't appear in File's Owner to connect to even though
I have two classes which need to be in same xml file. The way
Have two bean definitions: file a.xml <bean id=A class=com.A> <property name=bClass ref=B/> </bean> file
I have two collections, the first with an array of id's referencing documents in
I have downloaded two file form poin2 to listing property and i have to
I have two paragraphs of text, one is saved in a file while the

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.