An invalid XML character (Unicode: 0x4) was found in the element content of the
轉自網上:
An invalid XML character (Unicode: 0x4) was found in the element content of the document.
org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x4) was found in the element content of the document.
原因是在獲取InputStream的時候,使用了StringBufferInputStream(String
source)方法,這個方法在將String構造成InputStream的時候會破壞String原來的字元編碼。比如你使用的是gb2312,但是
它按照系統預設的編碼比如iso-8259-1或者Unicode-16之類來解析,那就會出現字元轉換錯誤。這裡面可能就剛好有一個被錯誤的轉換成了
Unicode:0x4, 所以就報了上面的錯。解決的方法是:
1 - 在轉換的時候宣告字元編碼,或者進行一下轉換(未嘗試,不知道是否可行)
2 - 使用ByteArrayInputStream來替代StringBufferInputStream。
相關文章
- An invalid XML character (Unicode: 0x18) was foundXMLUnicode
- Error parsing XML: An invalid XML character (Unicode:0x1f) was foundErrorXMLUnicode
- An invalid XML character (Unicode: 0x10) was found in the value of attributeXMLUnicode
- 微信公眾號 報 An invalid XML character (Unicode: 0x1a) was found in the CDATA sectioXMLUnicode
- All About JAVA An invalid XML character (Unicode: 0xdd65) was found in the comment 錯誤JavaXMLUnicode
- 對XML 進行 parse 時的Invalid Unicode character (0x0) 分析XMLUnicode
- Java - XML字元支援報錯An invalid XML characterJavaXML字元
- SAXParseException An invalid XML character 問題的解決ExceptionXML
- Dom4j 讀 xml 時,遇到 xml 無效字元,報錯:An invalid XML characterXML字元
- IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokensExceptionHTTP
- 已解決:Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986 問題
- Python 錯誤 SyntaxError: invalid character in identifierPythonErrorIDE
- mybatis3:Invalid bound statement (not found)MyBatisS3
- MyBatis 錯誤:Invalid bound statement (not found)MyBatis
- mybatis 報錯: Invalid bound statement (not found)MyBatis
- MySQL Invalid gbk character string 1300MySql
- React報錯之Element type is invalidReact
- Invalid bound statement (not found)錯誤解決
- not found service definition in jdonframework.xmlFrameworkXML
- DataPump Export (EXPDP) Fails With Error LPX-216 Invalid CharacterExportAIError
- no declaration can be found for element rabbit:connection-factory
- The content of element type "package" must match "(result-types?,interceptors?...Package
- JNI開發:Class android.content.Context could not be foundAndroidContext
- android.content.ActivityNotFoundException:UnabletofindexplicitactivityclasshaveyoudeclaredthisactivityinyourAndroidManifest.xml?AndroidExceptionIndexXML
- WebService異常Unexpected wrapper element ... found. Expected ...WebAPP
- IDEA+Maven:invalid bound statement (not found)解決辦法IdeaMaven
- error MSB8031 Building an MFC project for a non-Unicode character set is deprecatedErrorUIProjectUnicode
- AL32UTF8 / UTF8 (Unicode) Database Character Set Implications [ID 788156.1]UnicodeDatabase
- python 解析xml 檔案: Element Tree 方式PythonXML
- Jsp Unescaped xml character報錯的解決辦法JSXML
- PHP 對字串進行十六進位制替換 invalid character in attribute valuePHP字串
- java.sql.SQLException: ORA-00911: invalid character 解決方法(轉)JavaSQLException
- xml問題請教:org.xml.sax.SAXParseException: Invalid encoding name "GBK".XMLExceptionEncoding
- 執行mysqlbinlog出現Found invalid event in binary log錯MySql
- MybatisPlus自帶方法報錯BindingException: Invalid bound statement (not found)MyBatisException
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)ApacheBATException
- 解析XML檔案時,無效的XML 字元 (Unicode: 0x7)異常處理XML字元Unicode
- IDEA+Maven+Springboot:invalid bound statement (not found) 解決辦法IdeaMavenSpring Boot