获取提要时Java GData电子表格API失败
我正试图通过文档的键获取特定文档。我遵循这里的说明: 我从URL获取密钥: 它给了我以下例外情况:获取提要时Java GData电子表格API失败,java,google-sheets,gdata-api,Java,Google Sheets,Gdata Api,我正试图通过文档的键获取特定文档。我遵循这里的说明: 我从URL获取密钥: 它给了我以下例外情况: Exception in thread "main" com.google.gdata.util.ParseException: [Line 1, Column 165] Invalid root element, expected (namespace uri:local name) of (http://www.w3.org/2005/Atom:feed), found (http:/
Exception in thread "main" com.google.gdata.util.ParseException: [Line 1, Column 165]
Invalid root element, expected (namespace uri:local name) of (http://www.w3.org/2005/Atom:feed),
found (http://www.w3.org/2005/Atom:entry
这个例外真的没有多大意义。我猜它希望标签是根,但它越来越大了。如果我转到我用于feedUrl
的URL,那么我会得到我想要的XML文档(包含我想要的文档的名称和所有内容)。我不知道我在这里做错了什么,我在网上也找不到任何能帮助我的东西
有人看到我做错了什么吗?我知道这是一项令人讨厌的黑客工作,但由于找不到任何其他解决方案,我最终下载了com.google.gdata.wireformats.input.AtomDataParser的源代码,创建了一个Reader对象包装器,将预期的标记注入到正在解析的流中。我在AtomDataParser代码中更改了这一行:
feedResult.parseAtom(inProps.getExtensionProfile(), inputReader);
致:
如果您将电子表格提要与任何其他URL一起使用,这显然不起作用,但它适用于我所做的工作。feedUrl应该是“https://spreadsheets.google.com/feeds/spreadsheets/private/full/“对于回馈类型
feedResult.parseAtom(inProps.getExtensionProfile(), inputReader);
if(feedResult instanceof SpreadsheetFeed) {
feedResult.parseAtom(inProps.getExtensionProfile(), new utils.ReaderWrapper(inputReader));
} else {
feedResult.parseAtom(inProps.getExtensionProfile(), inputReader);
}