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?
I’d suggest using two handlers. As a trivial example (you’ll have to fill in the details):
It doesn’t look like there’s a way to find the parser that generated the event.