【发布时间】:2011-05-08 01:26:48
【问题描述】:
我正在编写一个从 Flickr API 下载数据的 iPhone 应用程序。目前似乎没有办法限制它下载的comments 的数量,虽然我想获得 8 个或 10 个,但它有时会发送给我数百个。我有subclassedASIHTTPRequest这样它只会下载一定数量的字节(例如,它会在收到1024字节的评论数据后停止下载)。
现在,我想解析的信息都在那里(评论数据包含用户 ID、文本等内容)。但是,由于它在结束之前被切断,因此 XML 格式错误,并且我当前的解决方案(使用 ObjectiveFlickr 的 XML 解析器)无法解析 XML。有没有办法处理格式错误的 XML,就像旧的 Web 浏览器处理 HTML 一样,只提取格式正确的数据?
这是一些示例数据:
<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="ok">
<comments photo_id="5692627867">
<comment id="49862655-5692627867-72157626659891768" author="29114051@N05" authorname="eαse*" iconserver="4046" iconfarm="5" datecreate="1304689286" permalink="http://www.flickr.com/photos/kikicchi/5692627867/#comment72157626659891768">lovely lovely lovelyyyyy!!! ♥♥♥♥♥♥♥♥♥</comment>
<comment id="49862655-5692627867-72157626535581359" author="49946698@N06" authorname="RandomPics Art" iconserver="4017" iconfarm="5" datecreate="1304692593" permalink="http://www.flickr.com/photos/kikicchi/5692627867/#comment72157626535581359">nice! like soft colors and tones!</comment>
<comment id="49862655-5692627867-72157626660240896" author="49907977@N06" authorname="kiki_chi" iconserver="4014" iconfarm="5" datecreate="1304693051" permalink="http://www.flickr.com/photos/kikicchi/5692627867/#comment72157626660240896">&gt;eαse*
&gt;RandomPics Art
Thank you:) :) :)</comment>
<comment id="49862655-5692627867-72157626660761230" author="41717031@N08" authorname="petia.bourova" iconserver="4082" iconfarm="5" datecreate="1304698244" permalink="http://www.flickr.com/photos/kikicchi/5692627867/#comment72157626660761230">Thank you!Very nice photo!I like The coulers very,very much!!!</comment>
<comment id="49862655-5692627867-72157626661258700" author="31540474@N08" authorname="Leentje32" iconserver="4067" iconfarm="5" datecreate="1304703576" permalink="http://www.flickr.com/photos/kikicchi/5692627867/#comment72157626661258700">Aww so lovely!! Beautiful capture.</comment>
<comment id="49862655-5692627867-72157626662413410" author="61373986@N06" authorname="My NIKON And Me" iconserver="5310" iconfarm="6" datecreate="1304716098" permalink="http://www.flickr.com/photos/kikicchi/5692627867/#comment72157626662413410">lovely image!!!</comment>
<comment id="49862655-5692627867-72157626663408864" author="7652657@N02" authorname="Majlee" iconserver="3130" iconfarm="4" datecreate="1304728344" permalink="http://www.flickr.com/photos/kikicchi/5692627867/#comment72157626663408864">This is just adorable !</comment>
<comment id="49862655-5692627867-72157626663519092" author="15613254@N05" authorname="mr_jyoti" iconserver="4011" iconfarm="5" datecreate="1304729940" permalink="http://www.flickr.com/photos/kikicchi/5692627867/#comment72157626663519092">Cool shot. Nice bokey.</comment>
<comment id="49862655-5692627867-72157626663642456" author="16327396@N03" authorname="my beanie hat rocks" iconserver="2550" iconfarm="3" datecreate="1304731810" permalink="http://www.flickr.com/photos/kikicchi/5692627867/#comment72157626663642456">Maybe she could cheer this fella up!!
<a href="http://www.flickr.com/photos/weasteman/5652855802/in/photostream">www.flickr.com/photos/weasteman/5652855802/in/photostream</a>
=D</comment>
【问题讨论】:
标签: iphone objective-c asihttprequest flickr