Can anyone please tell me how to solve the following XML Exception?
Character reference &#x1F is an invalid XML character
开发者_如何学C
I have a XML file with the character , When I try to parse this XML file I'm getting this Exception. Is there any way to resolve this?
The part of my code is like this...
File f = new File("sample.xml");
dom = db.parse(f);
I'm getting exception when I'm calling the function parse()
. I also tried with UTF8 encoding, and got the same exception.
Any help is much appreciated.
Thank u in advance!!!
As Michael Kay commented: There are more valid characters in XML 1.1 than in XML 1.0. In case the XML has a prolog that declares version 1.0 it might be sufficient to change the prolog from
<?xml version="1.0" >
to
<?xml version="1.1" >
If there are still invalid characters, you must decide how to deal with them. Streamflyer will ease your task.
You can create a class that extends FilterReader to skip invalid XML characters. See this link.
The XML file is invalid, and the parser is telling you so. The control character decimal 31, hex 0x1F, can't appear in XML source. You need to have a look at the file and see what's going on.
Here is a list a valid character entities. Perhaps from the context of your xml you can determine what it should be:
http://www.i18nguy.com/markup/ncrs.html
精彩评论