3
我正在從Web服務獲取XML作爲響應。這個XML中的其中一個標籤實際上包含了Web服務作爲流發送的文檔內容。如果我嘗試解析作爲NSString的,然後將其轉換爲NSData的加載到網頁視圖後,提取該文件,UIWebView中是不能夠顯示文檔,並引發錯誤:如何在iOS中從xml提取文檔流?
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中顯示。 我需要一些指導。
終於找到了解決辦法。基本上這個流是基於base64編碼格式。所以首先我需要解碼哪些會給我提供正確的NSData。使用任何base 64編碼/解碼庫 - 關閉 –