问题描述
我正在尝试使用 java 方法从 db 中获取以下 xml,但出现错误
I am trying to fetch the below xml from db using a java method but I am getting an error
用于解析 xml 的代码
Code used to parse the xml
数据
错误
我在一些线程中读到这是因为 xml 中的一些特殊字符.如何解决这个问题?
I read in some threads it's because of some special characters in the xml. How to fix this issue ?
推荐答案
如何解决这个问题?
How to fix this issue ?
使用正确的字符编码读取数据.错误消息意味着您正在尝试以 UTF-8 格式读取数据(有意或因为这是未指定 <?xml version="1.0" encoding="somethingelse 的 XML 文件的默认编码"?>
) 但它实际上采用不同的编码,例如 ISO-8859-1 或 Windows-1252.
Read the data using the correct character encoding. The error message means that you are trying to read the data as UTF-8 (either deliberately or because that is the default encoding for an XML file that does not specify <?xml version="1.0" encoding="somethingelse"?>
) but it is actually in a different encoding such as ISO-8859-1 or Windows-1252.
为了能够建议您应该如何执行此操作,我必须查看您当前用于读取 XML 的代码.
To be able to advise on how you should do this I'd have to see the code you're currently using to read the XML.
这篇关于如何修复 1 字节 UTF-8 序列的无效字节 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!