[Fatal Error] :1:1: Content is not allowed in prolog.
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:262)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:342)
at org.code2care.java.examples.SAXParseExceptionExample.main(SAXParseExceptionExample.java:21)
You may get the above error when you are trying to parse an XML file in Java using the Sax Parser and the XML file is incorrect.
The most common reason is that you have some text before the <?xml
Incorrect XML file:
data<?xml version="1.0" encoding="UTF-8"?>
<employees>
<employee>
<name>Sam Jose</name>
<dob>1990-05-15</dob>
<city>New York</city>
</employee>
...
...
Correct XML file:
<?xml version="1.0" encoding="UTF-8"?>
<employees>
<employee>
<name>Sam Jose</name>
<dob>1990-05-15</dob>
<city>New York</city>
</employee>
...
...
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Java,
- Java equals method - Tutorial
- Unbound classpath container: JRE System Library [JavaSE-1.7]
- Spring Boot: @RequestBody not applicable to method
- Java 8: Steam map with Code Examples
- Java Program: Random Number Generator
- Java java.time.Clock class code examples [Java Date Time API]
- Fix: type argument is not within bounds of type-variable T
- [Fix] java.net.MalformedURLException: unknown protocol
- Java 7 addSuppression() and getSuppression() Exception Handling
- Convert Java Array to ArrayList Code Example
- How to Word-Warp Console logs in IntelliJ
- Ways Compare Dates in Java Programming with Examples
- Remove Trailing zeros BigDecimal Java
- CRUD operations in Spring Boot + JDBC
- [Java Threads] Should we extend Thread Class or implement Runnable interface
- Json Serialization and Deserialization using Java Jackson
- Create simple struts2 project using maven commands
- How to install Java OpenJDK 11 on Alpine Linux
- Unsupported major.minor version 52.0 in java
- Error: Can not find the tag library descriptor for
- Java: Convert String to Binary
- How to run Java Unit Test cases with Apache Maven?
- Java: Testing Private Methods in JUnit using reflection API Example
- Java JDBC Connection with MySQL Driver in VS Code + Troubleshooting
- Java Join Strings with Comma Separator
More Posts:
- How to Change AWS Default Region using CLI - AWS
- Mac OS X Error: Could not create the Java Virtual Machine - Mac-OS-X
- cURL -x Use of HTTP Proxy Server Examples - cURL
- Java Join Strings with Comma Separator - Java
- Fix: AttributeError: str object has no attribute decode. Did you mean: encode?[Python] - Python
- Fix Maven: Could not find artifact in central - Java
- [IRCTC] Indian railways official eRail API 1.1 for developers to get train info - HowTos
- Define an Infinite Number in Python - Python