File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UTF-16 Encoding -Content is not allowed in prolog.

 
Abhi Venu
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a schema declaration with following prolog

<?xml version="1.0" encoding="UTF-16" standalone="yes"?>

Also i have generated a XML file based on this which has following prolog

<?xml version = '1.0' encoding="UTF-16"?>

My program that reads the XML file gives following error on execution .The data read occurs only if validation of XML with schema succeeds

But i always gets an error

"Error While Validating
Content is not allowed in prolog."

where am i going wrong?


But when i made following changes

<?xml version="1.0" encoding="windows-1252" standalone="yes"?>


<?xml version = '1.0' ?>(i.e skipped encoding )

I was not getting errors






Please tell where have i made mistake.I s this way to use UTF-16 encoding?












 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Content is not allowed in prolog.


Sometimes that error can be caused by something as simple as a leading blank line or a single leading spce in the file text.

Always doublecheck that the < is the very first character in the file.

Bill

 
Abhi Venu
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the reply.
No its not the problem . I found so many people saying about getting of this error due to a reason as you said.But in my case its not else it would have thrown the same error for the other one also rite...
 
Paul Clapham
Sheriff
Pie
Posts: 20166
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you should actually use UTF-16 for the encoding. Saying it's encoded in UTF-16 when it's actually encoded in some other charset is likely to cause problems. Perhaps even that one, I don't know.
 
Abhi Venu
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the reply . I will try once again changing it to UTF-16
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic