tags:

views:

146

answers:

0

Hello, I'm working on an iPhone app that will use Vimeo Simple API to give me a listing our videos by a certain user, in a convenient TableView format. I'm new to Parsing XML and have tried TouchXML, TinyXML, and now NSXMLParser with no luck. Most tutorials on parsing XML are for a blog, and not for an API XML sheet. I've tried modifying the blog parsers to search for the specific tags, but it doesn't seem to work.

Right now I'm working with NSXMLParser and it seems to correctly find the value of an XML tag, but when it goes to append it to a NSMutableString, it writes a whole bunch of nulls in between it. I'm using a tutorial from theappleblog and modifying it to work with Vimeo API

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
 if ([currentElement isEqualToString:@"video_title"]) {
  NSLog(@"String: %@",string);
  [currentTitle appendString:string];
 } else if ([currentElement isEqualToString:@"video_url"]) {
  [currentLink appendString:string];
 } else if ([currentElement isEqualToString:@"video_description"]) {
  [currentSummary appendString:string];
 } else if ([currentElement isEqualToString:@"date"]) {
  [currentDate appendString:string];
 }

Here is the nulls it writes: http://grab.by/grabs/92d9cfc2df4fac3fe6579493b1a8e89f.png

Then when it finishes, it has to add the NSMutableStrings into a NSMutableDictionary

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{   
    //NSLog(@"found this element: %@", elementName);
 currentElement = [elementName copy];

 if ([elementName isEqualToString:@"item"]) {
  // clear out our story item caches...
  item = [[NSMutableDictionary alloc] init];
  currentTitle = [[NSMutableString alloc] init];
  currentDate = [[NSMutableString alloc] init];
  currentSummary = [[NSMutableString alloc] init];
  currentLink = [[NSMutableString alloc] init];
 }
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{     
 NSLog(@"Title: %@",currentTitle);
 if ([elementName isEqualToString:@"item"]) {// save values to an item, then store that item into the array...
  [item setObject:currentTitle forKey:@"video_title"];
NSLog(@"Current Title%@", currentTitle);
  [item setObject:currentLink forKey:@"video_url"];
  [item setObject:currentSummary forKey:@"video_description"];
  [item setObject:currentDate forKey:@"date"];

  [stories addObject:[item copy]];
  NSLog(@"adding story: %@", currentTitle);
 }
 }

I would really appreciate it if someone has any advance