objective c - Results of XML parsing start from the last & found in the -


this question has answer here:

i'm using youtube api , getting results channel. when try description stops @ last & , part of description.

here's website i'm getting xml information http://gdata.youtube.com/feeds/api/users/smosh/uploads?max-results=1

- (void) parser:(nsxmlparser *)parser didendelement:(nsstring *)elementname namespaceuri:(nsstring *)namespaceuri qualifiedname:(nsstring *)qname {     if ([elementname isequaltostring:@"content"])     {         currentfeed.description = currentnodecontent;     }      if ([elementname isequaltostring:@"entry"])     {         [self.feeds addobject:currentfeed];         currentfeed = nil;         currentnodecontent = nil;     } } 

the content getting description video.

however these results

  wardrobe: paula barkley asst. editor: justin dailey | color: pretty moving pictures bts: phil mohr | key pa: brad westerbeck  ------------------------------------ hey it's our own website: http://smosh.com oh , our facebook page: http://facebook.com/smosh want know when we're filming and/or pooping? can:http://twitter.com/smosh guess should have google+ page, too: http://google.com/+smosh  

when whole description:

bloopers & alternate scenes: http://smo.sh/friendsxtras download our new game: http://smo.sh/headesploder  ian , anthony need new friends.  cast: anthony himself ian himself ryan todd stevie ryan cicak , robert haley new neighbors  written by: anthony padilla, ian hecox, & ryan finnerty produced & directed by: anthony padilla, ian hecox, & ryan todd edited by: anthony padilla & michael barryte post supervision by: ian hecox & ryan finnerty  ad: frank cosgriff | dp: john alexander jimenez asst. camera: shawna smith | sound mixer: palmer taylor gaffer: kerry sweeney | grips: jon hooker & lee eisenhower production design: patrick egan | mua & wardrobe: paula barkley asst. editor: justin dailey | color: pretty moving pictures bts: phil mohr | key pa: brad westerbeck  ------------------------------------  hey it's our own website: http://smosh.com oh , our facebook page: >http://facebook.com/smosh want know when we're filming and/or pooping? can:http://twitter.com/smosh guess should have google+ page, too: http://google.com/+smosh 

here's whole class file

your code assumes foundcharacters returns entire value element in single call. not valid assumption (especially long values). why you're seeing end of content tag, because rest of value returned in prior calls foundcharacters, discarded on each subsequent call foundcharacters.

for long value, sequence of events (a) call didstartelement; (b) multiple calls foundcharacters until whole value returned; , (c) call didendelement.

so:

  1. have didstartelement initialize currentnodecontent if encounters either title , content element names:

    currentnodecontent = [[nsmutablestring alloc] init]; 
  2. then, foundcharacters should append string currentnodecontent:

    [currentnodecontent appendstring:string]; 

    nb: make sure not trim string (if want trim, in didendelement, not in foundcharacters).

  3. have didendelement save currentnodecontent if element name title or content , should set currentnodecontent nil.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -