我正在尝试从 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)