解析XML时,org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 449: not well-forme
来源:互联网 发布:json和js对象的区别 编辑:程序博客网 时间:2024/06/04 19:03
解析XML时,org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 449: not well-forme
最近两天看mars老师的mp3播放器,一步一步跟着老师敲的代码,结果运行起来,解析xml时总是报错,表面上看程序执行到某一行不在执行:如下:
private List<Mp3Info> parse(String xmlStr){
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
List<Mp3Info> infos = new ArrayList<Mp3Info>();
try{
XMLReader xmlReader = saxParserFactory.newSAXParser().getXMLReader();
System.out.println("--------------2");
Mp3ListContentHandler mp3ListContentHandler = new Mp3ListContentHandler(infos);
System.out.println("--------------3");
xmlReader.setContentHandler(mp3ListContentHandler);
System.out.println("--------------4");
xmlReader.parse(new InputSource(new StringReader(xmlStr)));//这部开始错
System.out.println("--------------5");
for (Iterator<Mp3Info> iterator = infos.iterator(); iterator.hasNext();) {
Mp3Info mp3Info = (Mp3Info) iterator.next();
System.out.println("--------------6");
System.out.println(mp3Info);
}
}
catch(Exception e){
e.printStackTrace();
}
return infos;
}
看日志便是标题所示的错误:
org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 449: not well-formed
在网上查的时候发现了另外一个网友的一篇文章,遭遇我和类似,这是链接
http://blog.csdn.net/tts_kevin/article/details/6274110
在日志上有这样一处:
09-12 08:37:36.176: INFO/System.out(455): --------------2
09-12 08:37:36.176: INFO/System.out(455): --------------3
09-12 08:37:36.215: INFO/System.out(455): --------------4
09-12 08:37:36.215: INFO/System.out(455): ---startElement and tagName is resources
09-12 08:37:36.215: INFO/System.out(455): ---startElement and tagName is resource
09-12 08:37:36.215: INFO/System.out(455): ---startElement and tagName is id
09-12 08:37:36.215: INFO/System.out(455): tagName is not resource
09-12 08:37:36.246: INFO/System.out(455): ---startElement and tagName is mp3.name
09-12 08:37:36.246: INFO/System.out(455): tagName is not resource
09-12 08:37:36.256: INFO/System.out(455): ---startElement and tagName is mp3.size
09-12 08:37:36.266: INFO/System.out(455): tagName is not resource
09-12 08:37:36.266: INFO/System.out(455): ---startElement and tagName is lrc.name
09-12 08:37:36.266: INFO/System.out(455): tagName is not resource
09-12 08:37:36.266: INFO/System.out(455): ---startElement and tagName is lrc.size
09-12 08:37:36.266: INFO/System.out(455): tagName is not resource
09-12 08:37:36.266: INFO/System.out(455): tagName is not resource
09-12 08:37:36.266: INFO/System.out(455): tagName is resource
09-12 08:37:36.295: INFO/System.out(455): ---startElement and tagName is resource
09-12 08:37:36.295: INFO/System.out(455): ---startElement and tagName is id
09-12 08:37:36.295: INFO/System.out(455): tagName is not resource
09-12 08:37:36.295: INFO/System.out(455): ---startElement and tagName is mp3.name
09-12 08:37:36.295: INFO/System.out(455): tagName is not resource
09-12 08:37:36.295: INFO/System.out(455): ---startElement and tagName is mp3.size
09-12 08:37:36.295: INFO/System.out(455): tagName is not resource
09-12 08:37:36.315: INFO/System.out(455): ---startElement and tagName is lrc.name
09-12 08:37:36.327: INFO/System.out(455): tagName is not resource
09-12 08:37:36.327: INFO/System.out(455): ---startElement and tagName is lrc.size
09-12 08:37:36.327: INFO/System.out(455): tagName is not resource
09-12 08:37:36.327: INFO/System.out(455): tagName is not resource
09-12 08:37:36.327: INFO/System.out(455): tagName is resource
09-12 08:37:36.327: INFO/System.out(455): ---startElement and tagName is resource
09-12 08:37:36.327: INFO/System.out(455): ---startElement and tagName is id
09-12 08:37:36.356: INFO/System.out(455): tagName is not resource
09-12 08:37:36.385: INFO/System.out(455): ---startElement and tagName is mp3.name
在这里,第三段的只开始到了“---startElement and tagName is mp3.name”这里,因此感觉是XML文件出错了,而受上面一篇文章的提示,就应该是XML的问题,上面一篇文章也是说sb的问题,也就是XML的流中出现的问题。基本上这两个问题是一个类型的。后来发现XML文件出错,把<mp3.name>Jay Sean-Maybe.mp3</mp3.name>写成了<mp3.name>Jay Sean-Maybe.mp3</name>
菜鸟一个,大家勿笑
- 解析XML时,org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 449: not well-forme
- 解析xml时,报错:org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 75:not well-formed
- 解析xml时,报错:org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 4:not well-formed(invaild toke)
- org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: unknown encoding
- org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: unknown encoding
- 解析xml时,报错:WARN/System.err(207): org.apache.harmony.xml.ExpatParser$ParseException: At line 1,
- Android开发时出现org.apache.harmony.xml.ExpatParser$ParseException:not well-formed错误时,我所犯的错误
- org.apache.harmony.xml.ExpatParser$ParseException mismatched tag
- android用SAX解析xml文件时抛出org.apache.harmony.xml.ExpatParser$ParseException异常的解决方法
- jboss启动报org.jboss.security.auth.login.ParseException: Encountered "<?xml" at line 1, column 1. 异常
- org.apache.lucene.queryParser.ParseException: Encountered "<EOF>" at line 1, column 0.
- org.apache.lucene.queryParser.ParseException: Encountered "<EOF>" at line 1, column 0.
- org.apache.lucene.queryparser.classic.ParseException: Encountered "<EOF>" at line 1, column 0.
- org.apache.el.parser.ParseException: Encountered " ":" ": "" at line 1, column 1
- android SAX解析xml流时报ExpatParser$ParseException错误解决方法
- android-org.jdom2.input.JDOMParseException: Error on line 1: At line 1, column 1971: not well-formed
- Parse Fatal Error at line 1 column 1: Content is not allowed in prolog. org.xml.sax.SAXParseExceptio
- ognl.ExpressionSyntaxException: Malformed OGNL expression: <?xml version [ognl.ParseException: Encountered " <" at line 1, colum
- CSS设置hr样式
- 固件挂载
- erlang文件操作
- Android 隐式意图和显示意图
- Go 语言中 channel 使用总结
- 解析XML时,org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 449: not well-forme
- 最大子段和算法 不同复杂度方法实现
- Java高效编程之二【对所有对象都通用的方法】
- Ubuntu下手机USB 显示??? insufficient permissions for device
- D3D中的世界矩阵,视图矩阵,投影矩阵
- JS字符串拼接的问题
- foreach使用方法 和 枚举使用方法
- Pick Game
- "The MathType DLL cannot be found.Please reinstall MathType"问题解决