Track.getSimilar:在元素中找到了无效的XML字符(Unicode:0x3)...

FRI*_*rad 4 java xml unicode arabic last.fm

我使用last.fm API:Api Last.fm

我有他们的艺术家的歌曲(曲目)列表,我想恢复每首歌曲,如他的歌曲.Track.getSimilar(Artist,track,key)的方法非常有效.但是当艺术家或曲目使用阿拉伯语时,我会遇到以下异常:

    [Fatal Error] :2583:13: An invalid XML character (Unicode: 0x3) was found in the element content of the document.
Exception in thread "main" de.umass.lastfm.CallException: org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x3) was found in the element content of the document.
at de.umass.lastfm.Caller.call(Caller.java:268)
at de.umass.lastfm.Caller.call(Caller.java:189)
at de.umass.lastfm.Track.getSimilar(Track.java:369)
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题呢?

先感谢您

jas*_*sso 7

Unicode代码点0x3是一个控制字符.它不是任何脚本或语言系统中的正常字符,因此它的存在显然是一个错误,可能在数据库本身.这可能是编码转换失败,字符到字节转换或数据库写入损坏的结果.

XML不能包含控制字符 - 甚至不包含实体引用.因此,您的XML格式不正确,无法使用XML工具进行处理.相反,您需要使用字符串处理或类似方法删除该错误字符.

同时,您可以检查XML中非法的所有其他字符.XML不允许来自Unicode代理块[0xD800 - 0xDFFF],非字符0xFFFE和/ 0xFFFF或下面的字符0x20(=控制字符)execpt 0x9 [tab],0xA[LF]和0xD[CR]中的任何字符.这在此正式陈述:http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char