Reading UTF-7 XML document in Java
843834Jul 15 2009 — edited Jul 15 2009I have an XML document and I want to add PrcessingInstruction to it.
<?xml version="1.0" encoding="UTF-7" ?>
<root_element>
<sections>
<section_introduction>
<order-no>108800674</order-no>
<order-type>219</order-type>
<created-date>5. november 2008</created-date>
....
.....
when trying to parse it like
File tmpFile = new File("C:\\ProvisioningEventError58412.xml");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
Document doc = factory.newDocumentBuilder().parse(tmpFile);
System.out.println("end");
I get an exception on Document doc = factory.newDocumentBuilder().parse(tmpFile);
org.xml.sax.SAXParseException: Invalid encoding name "UTF-7".
[Fatal Error] ProvisioningEventError58412.xml:1:40: Invalid encoding name "UTF-7".
Is it possible to set encoding on DocumentBuilder, so it can work with UTF-7 or is there any other was to parse it for adding ProcessingInstruction. Actually I want to add a CSS/XSL file for formatting the XML File.
Edited by: aamaam on Jul 15, 2009 5:18 AM