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
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:
have
didstartelement
initializecurrentnodecontent
if encounters eithertitle
,content
element names:currentnodecontent = [[nsmutablestring alloc] init];
then,
foundcharacters
should appendstring
currentnodecontent
:[currentnodecontent appendstring:string];
nb: make sure not trim string (if want trim, in
didendelement
, not infoundcharacters
).have
didendelement
savecurrentnodecontent
if element nametitle
orcontent
, should setcurrentnodecontent
nil
.
Comments
Post a Comment