• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

XML String to Document

 
Ranch Hand
Posts: 57
  • 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
 
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!