File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML String to Document

 
Paulo Carvalho
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I have a XML String which I want to convert to a Document object. To do so I made a method "stringToDocument(final String xmlSource)".



However I have a problem. My XML String have the following header:

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>

When I convert my XML String to a Document object, if I print the resulting Document into a String it has the following header:

<?xml version="1.0" encoding="UTF-8"?>

This causes me problems for next processes that I apply to the generated XML.

How can I convert my XML String to a Document keeping the original header?

Thanks
Regards
 
Paul Clapham
Sheriff
Pie
Posts: 20188
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Keeping the original header" isn't a reasonable requirement. The prolog is supposed to describe the document it is attached to, and that should be your requirement. So the encoding should declare the actual encoding of the document, and you should only have a "standalone" attribute in your prolog if the document is standalone.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic