Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

An invalid XML character (Unicode: 0x0) was found in the prolog of the docu

843834Dec 15 2004 — edited Dec 17 2004
Hi 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 14 2005
Added on Dec 15 2004
2 comments
1,789 views