gpt4 book ai didi

iphone - NSXMLParser rss 图像 url?

转载 作者:行者123 更新时间:2023-12-03 20:45:56 26 4
gpt4 key购买 nike

我正在使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com