Hi Kalpesh, I don't think this possibility exists in SAX right now and that it will be planned for future releases... The question is really why would you need such feature to exist in SAX? Why would you need to access the standalone or encoding attributes of the XML prologue when parsing a XML file? If you absolutely need to doing this without DOM level3, you may open the document yourself and parse the xml decl. This shouldn't be too hard as the xml decl grammar is very simple. The only tricky bit is managing to read with the correct encoding as caracters are 1 or 2 bytes wide (for the UTF-16 familly of charsets). Now, if you now that your XML documents are not using wide charsets, you can assume you're always having 1 byte per char. Cheers
Joined: Nov 22, 2008
OK, I found a way of doing this is you're using Xerces as your favourite SAX parser. Please note that the following code is based on the actual implementation of Xerces and will not work if you're using a different parser.
The contents of the xmlDeclTest.xml file is as follows:
As expected, when running the XMLDeclSAXParser class, the output gives:
Hope this helps
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com