如何从iOS中的xml中提取文档流?

时间:2012-10-09 19:10:53

标签: objective-c ios uiwebview xml-parsing

我从Web服务获取XML作为响应。此xml中的一个标记实际上包含Web服务作为流发送的文档的内容。如果我在解析为NSString后尝试解压缩文档,然后将其转换为NSData以加载到webView中,则UIwebView无法显示文档并引发错误:

EXCEPTION CPMessageException: (null)

以下是我作为回复得到的xml示例(我无法提供确切的xml,因为它是保密的):

<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><content xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns6:BinaryContent" pageModifier="" pageNumber="0" format="msw8"><ns6:renditionType>PRIMARY</ns6:renditionType><ns6:Value>0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAACAAAAvAAAAAAAAAAAEAAAvwAAAAEAAAD+////AAAAALoAAAC7AAAA///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////spcEABYAJBAAA+BK/AAAAAAAAEAAAAAAACAAAT0oAAA4AYmpiahr3GvcAAAAAAAAAAAAAAAAAAAAAAAAJBBYAOFoAAHidAAB4nQAAQUIAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAAAAAAAAD//w8AAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAALcAAAAAAO4bAAAAAAAA7hsAAGAoAAAAAAAAYCgAAAAAAABgKAAAAAAAAGAoAAAAAAAAYCgAABQAAAAAAAAAAAAAAP////8AAAAAdCgAAAAAAAB0KAAAAAAAAHQoAAA4AAAArCgAAAwAAAC4KAAANAAAAHQoAAAAAAAAyz4AAGYBAADsKAAAAAAAAOwoAAAAAAAA7CgAAAAAAADsKAAAAAAAAOwoAAAAAAAAHCsAAAAAAAAcKwAAAAAAABwrAAAAAAAASj4AAAIAAABMPgAAAAAAAEw+AAAAAAAATD4AAAAAAABMPgAAAAAAAEw+AAAAAAAATD4AACQAAAAxQAAAogIAANNCAABaAAAAcD4AABUAAAAAAAAAAAAAAAAAAAAAAAAAYCgAAAAAAAAcKwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcKwAAAAAAABwrAAAAAAAAHCsAAAAAAAAcKwAAAAAAAHA+AAAAAAAAAAAAAAAAAABgKAAAAAAAAGAoAAAAAAAA7CgAAAAAAAAAAAAAAAAAAOwoAAAwAgAAhT4AABYAAABaLAAAAAAAAFosAAAAAAAAWiwAAAAAAAAcKwAAygAAAGAoAAAAAAAA7CgAAAAAAABgKAAAAAAAAOwoAAAAAAAASj4AAAAAAAAAAAAAAAAAAFosAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHCsAAAAAAABKPgAAAAAAAAAAAAAAAAAAWiwAAAAAAABaLAAApgEAAJY7AACMAQAAAAAAA</ns6:Value></content></S:Body></S:Envelope>

我需要提取<ns6:Value>,它实际上是文档的内容,并在UIwebView中显示。 我需要一些指导。

1 个答案:

答案 0 :(得分:1)

终于找到了解决方案。基本上,流以base64编码格式出现。所以首先我需要解码,它将为我提供正确的NSData。使用任何base 64编码/解码库。