如何限制iphone中的xml解析

如何限制iphone中的xml解析,iphone,objective-c,xml-parsing,Iphone,Objective C,Xml Parsing,我是iphone开发新手。我想从xml文件解析一个图像url,并将其显示在RSS提要中。有三个图像url,但我只想检索一个url并显示它 <entry> <id>xxxxx</id> <title>xxx xxxx xxxx</title> <content>xxxxxxxxxxx</content> <media:group> <media:thumbnail url="http://tige

我是iphone开发新手。我想从xml文件解析一个图像url,并将其显示在RSS提要中。有三个图像url,但我只想检索一个url并显示它

<entry>
<id>xxxxx</id>
<title>xxx xxxx xxxx</title>
<content>xxxxxxxxxxx</content>
<media:group>
<media:thumbnail url="http://tiger.jpg"/>
<media:thumbnail url="http://lion.jpg"/>
<media:thumbnail url="http://elephan.jpg"/>
</media:group>
</entry>

我只想检索tiger图像。请帮助我。谢谢。

在这个特殊的实例中,您可以设置一个类变量,而不是当前的本地myUrl,一旦您在其中获得一个值。在下面的代码中,这假设您从未在其他任何地方初始化myURL

if (myURL == nil)
    myUrl = [attributeDict objectForKey:@"url"];
然而,如果您总是想要第一个缩略图URL,那么这只会按照您期望的方式工作。除非你有一些保证(你没有提到),你会一直想要第一个URL,那么你真的没有什么办法可以抓住你不想要第一个URL的情况,因为所有的缩略图URL标签和属性都是相同的保存为URL

if (myURL == nil)
    myUrl = [attributeDict objectForKey:@"url"];