【问题标题】:Parser for MIME Type 'text/xml charset=utf-8'MIME 类型 'text/xml charset=utf-8' 的解析器
【发布时间】:2012-02-17 12:11:30
【问题描述】:

我正在使用 restkit,但在解析 xml 时遇到问题:

Unable to find parser for MIME Type 'text/xml charset=utf-8'
Encountered unexpected response with status code: 200 (MIME Type: text/xml charset=utf-8)

不支持吗?

【问题讨论】:

  • mime 类型应该只是“text/xml”,字符集不应该是 mimetype 的一部分。您可以更改/验证服务器 API 吗?
  • 不幸的是我不能。我接到了一个服务器的电话,我不得不猜测所有
  • "charset" 是某些 MIME 类型的有效参数;但是,它应该以分号开头,如“text/xml;charset=utf-8”。

标签: objective-c ios xml parsing restkit


【解决方案1】:

如果您无法修改服务器,只需在 RKParserRegistry 中使用 XML 解析器注册 mimetype:

[[RKParserRegistry sharedRegistry] setParserClass:[[[RKParserRegistry sharedRegistry] parserForMIMEType:RKMIMETypeXML] class] 
                                      forMIMEType:@"text/xml charset=utf-8"];

【讨论】:

    猜你喜欢
    • 2016-12-19
    • 2017-09-01
    • 1970-01-01
    • 2019-11-23
    • 2011-07-12
    • 2023-03-30
    • 2019-01-21
    • 1970-01-01
    • 2015-03-02
    相关资源
    最近更新 更多