iphone - NSXMLParser rss 图像 url?

标签 iphone objective-c parsing

我正在使用 nsxmlparser 解析 rss,我想从 rss 中获取一些图像...我该怎么做?

这是 RSS 的示例

<p><img scr = "IMGURL"></p>

如何获取“IMGURL”

谢谢, TC

最佳答案

这是一个快速技巧 - 仅当您知道字符串不会改变位置时才执行此操作。否则你就有崩溃的风险。

//for demo purposes lets say your <p><img scr = "IMGURL"></p> is a string named sourceString
//chop it up into an array like this and grab it from the arrays position

//create an array 
NSArray *tempArray = [sourceString componentsSeparatedByString:@"\""];

//what this has done, it has create an array of objects from your source string separated by "
//so in your tempArray you will have two objects
// objectAtIndex 0  will be: <p><img scr =    you wont need this so we can ignore it
// objectAtIndex 1  will be the string you want. it will be: IMGURL
// so now you can quickly create a string from it like this
NSString * imgURL = [[tempArray objectAtIndex:1]description]; 

这是一个快速而肮脏的伎俩......但它有效!只要数据保持相同的格式即可。你的电话!

关于iphone - NSXMLParser rss 图像 url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6865258/

相关文章:

iphone - 多个 UILabel 实例

iOS MPVolumeView 基于 AudioSession Mode 中断

java - joda - 解析 RSS 项中 pubDate 的时区

iphone - 将 iPhone 上的 stderr 写入文件和控制台

iphone - 我可以在 9 月之前学习 iPhone SDK 并完成一个应用程序吗?

iphone - 如何使用 UIGestureRecognizer 检测圆周运动

ios - 字符串中的特定颜色

c++ - 使用 Boost.spirit 解析一个简单的重复文本宏

Python urlparse 给出错误的结果

iphone - 为什么我的观察员未注册?