开发者

XML parsing works with Chrome and Firefox but fails on Internet Explorer

开发者 https://www.devze.com 2023-03-12 17:35 出处:网络
In my GWT project I am parsing a xml file: Document document = XMLParser.parse(xmlString); On Chrome and Firefox everything is fine. XML gets parsed succesfully and data retrieved is valid. But Int

In my GWT project I am parsing a xml file:

Document document = XMLParser.parse(xmlString);

On Chrome and Firefox everything is fine. XML gets parsed succesfully and data retrieved is valid. But Internet Explorer 9 the line above fails with the following exception:

com.google.gwt.xml.client.impl.DOMParseException: Failed to parse: <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> 
<parsedVolcanoes> 
<volcano> 
<title>V开发者_如何学Goulkan Arenal in Costa Rica</t

Any hints what might be the problem are highly appreciated! I am aware the given information is sparse so please ask if you need more information.

I was able to solve the problem. There is a 0xffff character in xmlString. Removing fixes the problem. Here is the code:

// remove invalid characters from xml
xmlString = xmlString.replaceAll("\\uffff", "");

// parse the XML document into a DOM
Document document = XMLParser.parse(xmlString);


Try removing the encoding="ISO-8859-1" from your XML declaration.

The second error indicates that you started off with a Unicode byte-order mark (or you called the LoadXML method), and then an encoding attribute specified something other than a 2-byte encoding (such as UTF-8 or Windows-1250)

— http://msdn.microsoft.com/en-us/library/aa468560.aspx#xmlencod_topic3

0

精彩评论

暂无评论...
验证码 换一张
取 消