iphone - UIWebView and an Encoded HTML String? -
i'm working on iphone project. getting html fragment rss feed , attempting load uiwebview using loadhtmlstring method.
the string receiving feed html encoded. when pass webview, displays decoded html, meaning shows tags along content of page.
is there way in objective-c decode html prior passing uiwebview?
edit: adding example of encoded html:
it's long passage, here's snippet:
<li>wireless data: wi-fi (802.11b/g), nike + ipod support built in, maps location-based service, bluetooth 2.1 + edr</li> <li>audio frequency response:&#160;20hz 20,000hz</li> <li>audio formats supported: <span>aac </span>(16 320 kbps), protected <span>aac </span>(from itunes store), <span>mp3 </span>(16 320 kbps), <span>mp3 vbr</span>, audible (formats 2, 3, , 4), apple lossless, <span>wav</span>, , <span>aiff</span></li> <li>photo support: syncs ipod-viewable photos in <span>jpeg</span>, bmp, <span>gif</span>, tiff, <span>psd </span>(mac only), , <span>png</span> formats</li> <li>tv out support: 480p , 576p</li> <li>video support: h.264 video, 1.5 mbps, 640 480 pixels, 30 frames per second, low-complexity version of h.264 baseline profile <span>aac</span>-lc audio 160 kbps, 48khz, stereo audio in .m4v, .mp4, , .mov file formats; h.264 video, 2.5 mbps, 640 480 pixels, 30 frames per second, baseline profile level 3.0 <span>aac</span>-lc audio 160 kbps, 48khz, stereo audio in .m4v, .mp4, , .mov file formats; <span>mpeg</span>-4 video, 2.5 mbps, 640 480 pixels, 30 frames per second, simple profile <span>aac</span>-lc audio 160 kbps, 48khz, stereo audio in .m4v, .mp4, , .mov file formats</li> <li>environmental requirements: operating temperature: 32° 95° f (0° 35° c); nonoperating temperature: -4° 113° f (-20° 45° c), relative humidity: 5% 95% noncondensing</li>
the quick , dirty way use -stringbyreplacingoccurrencesofstring:withstring: replace encoded xml entities equivalent characters:
nsstring *fragment = ...; // fragment rss feed [fragment autorelease]; // if not autoreleased prevent memory leak fragment = [fragment stringbyreplacingoccurrencesofstring:@"<" withstring:@"<"]; // repeat > & " etc.
there other options: use similar methods on nsmutablestring, regular expressions (ios 4 or regexkitlite) or write simple parser, way work fine if html fragments aren't huge.
Comments
Post a Comment