The encoding in your XML and XSD (or DTD) are different.
XML file header: <?xml version='1.0' encoding='utf-8'?>
XSD file header: <?xml version='1.0' encoding='utf-16'?>
Another possible scenario that causes this is when anything comes before the XML document type declaration. i.e you might have something like this in the buffer:
helloworld<?xml version="1.0" encoding="utf-8"?>
or even a space or special character.
There are some special characters called byte order markers that could be in the buffer. Before passing the buffer to the Parser do this…
String xml = "<?xml ..."; xml = xml.trim().replaceFirst("^([\\W]+)<","<");
Related Posts:
- In Java, how do I parse XML as a String instead of a file?
- How to convert/parse from String to char in java?
- How to parse JSON in Java
- Error parsing data org.json.JSONException: Value
- What is Parse/parsing?
- Which HTML Parser is the best?
- What is the best/simplest way to read in an XML file in Java application?
- How to parse JSON in Java
- Converting JSON to XML in Java
- align text center with android
- How to read json file into java with simple JSON library
- javax.xml.bind.UnmarshalException: unexpected element (uri:””, local:”Group”)
- org.xml.sax.SAXParseException: Content is not allowed in prolog
- HTTP Status 500 Error instantiating servlet class
- How to read and write XML files?
- Cannot resolve symbol ‘button’ -Android Studio
- Parsing JSON string in Java
- Error: The processing instruction target matching “[xX][mM][lL]” is not allowed
- android.content.res.Resources$NotFoundException: String resource ID #0x0
- How to set menu to Toolbar in Android
- Http status 401 This request requires HTTP authentication (). in tomcat 6
- Android Studio 2.2.3: Gradle project sync failed. Basic functionality (e.g. editting, debugging) will not work properly
- Spring Boot – Cannot determine embedded database driver class for database type NONE
- Initialization of an ArrayList in one line
- Is there a Heap in java?
- What’s the difference between map() and flatMap() methods in Java 8?
- Why do we need copy constructor and when should we use copy constructor in java
- What are the -Xms and -Xmx parameters when starting JVM?
- How to match “any character” in regular expression?
- Non-static variable cannot be referenced from a static context
- JAVA invalid maximum heap size. The specified size exceeds the maximum representable size
- JDK9: An illegal reflective access operation has occurred. org.python.core.PySystemState
- A long bigger than Long.MAX_VALUE
- How to remove single character from a String
- in java what does the @ symbol mean?
- How to call a method in another class in Java?
- unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- Java, “Variable name” cannot be resolved to a variable
- How to convert a Binary String to a base 10 integer in Java
- Java Method Stubs
- What’s the purpose of META-INF?
- JVM Crash – “EXCEPTION_ACCESS_VIOLATION”
- How to connect to FTP over TLS/SSL (FTPS) server in Java
- How to check type of variable in Java?
- How to solve error: ‘;’ expected in Java?
- Making a Java Makefile
- Censored Words Condition
- method in class cannot be applied to given types
- unused import statement for used ones in IntelliJ IDEA
- Unsigned long in Java
- Integer range when using 64bit jdk
- Removing whitespace from strings in Java
- what is this ANT build?
- org.glassfish.jersey.servlet.ServletContainer ClassNotFoundException
- hat is the purpose of flush() in Java streams?
- How can I convert integer into float in Java?
- How can I avoid this Ant Build error?
- Java Comparator class to sort arrays
- (The Triangle class) Design a class named Triangle that extends GeometricObject
- Cannot assign requested address using ServerSocket.socketBind
- Consider defining a bean of type ‘package’ in your configuration [Spring-Boot]
- Java – How to do floor division?
- Short form for Java if statement
- How can I convert a long to int in Java?
- org.apache.jasper.JasperException: Unable to compile class for JSP:
- How do I parse command line arguments in Java?
- Missing method body, or declare abstract in Java
- java code is showing error. ( ‘;’,expected)
- Efficient swapping of elements of an array in Java
- local variables referenced from an inner class must be final or effectively final
- hibernate properties not found
- Make a simple timer in Java
- How to switch scenes in JavaFX
- Corrupt jar file
- ReferenceError: “alert” is not defined
- How to write an ArrayList of Strings into a text file?
- Convert boolean to int in Java
- How to convert a String to CharSequence?
- Aspect Ratio with 800×480
- How do I convert a String to a BigInteger?
- How to set JAVA_HOME in Linux for all users
- What is ‘PermSize’ in Java?
- Jackson with JSON: Unrecognized field, not marked as ignorable
- Create a two dimensional string array anArray[2][2]
- Convert double to Int, rounded down
- A beginner’s error (args[0]) [duplicate]
- Converting from byte to int in Java
- How can I wait for 10 second without locking application UI in android [duplicate]
- Java error “Value of local variable is not used”
- Is there a way to end the program if statement is false?
- ArithmeticException: “Non-terminating decimal expansion; no exact representable decimal result”
- convert string to arraylist
in java - how to use drawArc()
- How to add RGB values into setColor() in Java?
- Can you write virtual functions / methods in Java?
- Creating video player using Java
- Can I override and overload static methods in Java?
- How can i fix this equals on primitive type(int)
- Can’t seem to disable Java Automatic Update