An invalid XML character (Unicode: 0x0) was found in the prolog of the docu
843834Dec 15 2004 — edited Dec 17 2004Hi folks,
I'm using the SAX parser to parse a small xml file. If I use that file in IE, there its parsing correctly and displaying the xml in the tree structure.
But in my Java code its throwing
org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x0) was found in the prolog of the document.
The xml parsing code of my program is
XMLReader parser = XMLReaderFactory.createXMLReader(
"org.apache.xerces.parsers.SAXParser");
HelpPartHandler hp = new HelpPartHandler();
parser.setContentHandler(hp);
RandomAccessFile raf = new RandomAccessFile("sample.xml","r");
byte Contents[] = new byte[(int)raf.length()];
StringReader sr = new StringReader(new String(Contents));
InputSource is = new InputSource(sr);
parser.parse(is);
The xml file is
<?xml version="1.0"?>
<ROOT>
<NODE> Java </NODE>
</ROOT>
Please let me know the mistakes what I have done. Looking for the reply.
Thanks in Advance
Prabu