I tried several things to solve it (ie changing the encoding, typing the XML file rather than copy-pasting it ect) in Notepad and XML Notepad but nothing worked.
The problem got solved when I edited and saved my XML file in Notepad (encoding -- For all those that get this error: WARNING: Catalina.start using conf/server.xml: Content is not allowed in prolog. but what this actually means is that there is garbage in your conf/file. this error can be caused by making changes with a text editor which introduces the garbage.
If so, you would create an XMLStream Reader, and just call "reader.next()" as long as "Next()" returns true.
SAXParse Exception: Content is not allowed in prolog. Error Handler Wrapper.create SAXParse Exception(Unknown Source) at org.apache.
If all else fails, open the file in binary to make sure there are no funny characters [3 non printable characters at the beginning of the file that identify the file as utf-8] at the beginning of the file. so we converted the file from utf-8 to ascii and it worked.
File file = new File("c:\file.xml"); Input Stream input Stream= new File Input Stream(file); Reader reader = new Input Stream Reader(input Stream,"UTF-8"); Input Source is = new Input Source(reader); Encoding("UTF-8"); I followed the instructions found here and i got the same error.
Yes, it will check that the document follows the rules of "well-formedness" set out by the XML spec - w3.org/TR/xml/#sec-well-formed.
This means that all elements must be closed, nested properly, etc.
In that case, there is sample code to do exactly the same thing using SAX here: edankert.com/No problem.XMLError Reporter.report Error(Unknown Source) at org.apache. XMLError Reporter.report Error(Unknown Source) at org.apache. XMLScanner.report Fatal Error(Unknown Source) at org.apache. XMLDocument Scanner Impl$Prolog Dispatcher.dispatch(Unknown Source) at org.apache. SOAPEnvelope(Message.java:435) at org.axis.security. WSDo All Receiver.invoke(WSDo All Receiver.java:114) at org.strategies. Simple Chain.invoke(Simple Chain.java:83) at org.client. Axis Client.invoke(Axis Client.java:198) at org.client. Added: Is that dash in front of your prolog part of the document?XMLDocument Fragment Scanner Document(Unknown Source) at org.apache.xerces.parsers. Deserialization Context.parse(Deserialization Context.java:227) at org. Invocation Strategy.visit(Invocation Strategy.java:32) at org. That would be the error there, having data in front of the prolog, My answer wouldn't help you probably, but it help with this problem generally.Getting this bug could be the case that one simply hits the delete key or some other key randomly when they have an XML window as the active display and are not paying attention.This has happened to me before with the file in my web application. We had the same problem recently and it turned out to be the case of a bad URL and consequently a standard 403 HTTP response (which obviously isn't the valid XML the client was looking for).
I've been trying to figure out how to check the syntax of an XML file, make sure all tags are closed, there's no random characters, etc... but I realized that I don't want to validate the structure of the XML file; I don't want to validate against an XML Schema (XSD)...