【发布时间】:2012-06-29 04:01:28
【问题描述】:
我正在尝试解析来自 google api 的数据:
http://gdata.youtube.com/feeds/base/videos?q=kittens&client=ytapi-youtube-search&v=2&start-index=1
像这样
try {
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(new InputSource(new StringReader(xml.trim())));
} catch (ParserConfigurationException e) {
System.out.println("XML parse error: " + e.getMessage());
return null;
} catch (SAXException e) {
System.out.println("Wrong XML file structure: " + e.getMessage());
return null;
} catch (IOException e) {
System.out.println("I/O exeption: " + e.getMessage());
return null;
}
并且不断收到“SAXException”.. 我做错了什么?
准确的错误信息是:I/System.out(19026): Wrong XML file structure: Unexpected token (position:TEXT null@1:104174 in java.io.StringReader@410c2448)
【问题讨论】:
-
如果打印出xml,它是什么样子的? (你确定它得到了所有的东西,等等?)
-
在 Eclipse 中,如果我打印它,它只会显示它的开头和结尾..(请原谅我不知道如何做这些事情,我是初学者@CasualT
-
为什么会有人反对这个?我试图澄清问题,提供样本数据,并准确解释我在做什么??如果这个问题太简单了,那么请帮我一个简单的答案。我是初学者,可以使用帮助。如果我应该以不同的方式提出问题,请告诉我。
标签: java android xml-parsing