Programming Tips - Java: Get the XML version and encoding with the SAX parser

Date: 2013oct22 Language: Java Q. Java: Get the XML version and encoding with the SAX parser A. Make setDocumentLocator() in your handler like this:
@Override public void setDocumentLocator(Locator locator) { if (locator instanceof Locator2) { Locator2 loc2 = (Locator2) locator; String ver = loc2.getXMLVersion(); String enc = loc2.getEncoding(); } }