Dave's Brain

Browse - Programming Tips - How can I get the XML version and encoding with the SAX parser?

Date: 2013oct22
Language: Java

Q.  How can I 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(); } }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.