【问题标题】:XML Parser for robospice-google-http-client?robospice-google-http-client 的 XML 解析器?
【发布时间】:2013-09-10 04:44:11
【问题描述】:

我想使用 robospice-google-http-client 解析 XML 响应。我可以按如下方式解析 json 响应。

HttpRequest request = getHttpRequestFactory()//
                .buildGetRequest( new GenericUrl( url) );
        request.setParser(new JacksonFactory().createJsonObjectParser());
        return request.execute().parseAs( getResultType() );

如何解析 XML? 我试过这个

request.setParser(new XmlObjectParser(new XmlNamespaceDictionary().set("", "test")));

但是会抛出一个错误说

java.lang.IllegalArgumentException: invalid XML: no alias declared for namesapce <>; work-around by setting XML namepace directly by calling the set method of com.google.api.client.xml.XmlNamespaceDictionary

我厌倦了设置命名空间但没有运气

【问题讨论】:

  • 你能提供你的 xml 和 POJO 类的例子吗?我无法在我的应用中进行解析。

标签: android xml robospice google-http-client


【解决方案1】:

通过设置 new XmlNamespaceDictionary().set("", "") 解决了这个问题

【讨论】:

    猜你喜欢
    • 2015-06-09
    • 2017-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-13
    • 1970-01-01
    相关资源
    最近更新 更多