unable to extract image url in xml parsing in iphone

I am quite new to the iphone development, I am using xml parsing to parse contents of a feed

this feed contains this line

<enclosure url="http://www.abc.com/wp-content/uploads/2010/01/abc.jpg" length="64690" type="image/jpg" />

no I want to extract http://www.abc.com/wp-content/uploads/2010/01/abc.jpg

XML structure is like this

<item>
<title>ABC</title>

<description>asgafgfafdasf</description>

<enclosure url="http://www.abc.com/wp-content/uploads/2010/01/abc.jpg" length="64690" type="image/jpg" />

</item>

I got values corresponding to description and tile

but unable to put down logic to parse that image url

CAn any bosy shed some light on this.

Thanx in advance

Answers


url value (as well as length and type) is element's attribute. If you use NSXMLParser then in delegate's didStartElement method you can get it using: (you may also want to check if data is valid while retrieving it)

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName 
    attributes:(NSDictionary *)attributeDict {
...
   if ([elementName equalsToString:@"enclosure"]){
      NSString* myUrl = [NSString stringWithString:[attributeDict objectForKey:@"url"]];
   }
...
}

Need Your Help

validating IP address - python

python regex validation split ip-address

I need to write a script that prints out a statement stating whether an IP is valid or invalid.

Date vs Calendar parsing

java calendar

That is unfair that java will close the methods of Date in next versions! yesterday I have wrote a code that parse a Data value from string and now how could I use that calendar for getting seconds,

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.