ios - NSXMLParser, getting strange issue while parsing data from web service -


i using async method of calling web service ipad app.

i receive correct data separated '**' like

420031****new****2372–2398, nw maynard rd cary north carolina united states2372–2398, nw maynard rd

connectiondidfinishloading:(nsurlconnection *)connection -- gives me correct data...

-(void)connectiondidfinishloading:(nsurlconnection *)connection {     if( m_xmlparser )     {         [m_xmlparser release];     }      m_xmlparser = [[nsxmlparser alloc] initwithdata: m_webdata];     [m_xmlparser setdelegate: self];     [m_xmlparser setshouldresolveexternalentities: yes];     [m_xmlparser parse]; } 

after below delegates called

-(void)parser:(nsxmlparser *)parser foundcharacters:(nsstring *)string { } 

i checked string instead of "420031****new****2372–2398, nw maynard rd cary north carolina united states2372–2398, nw maynard rd" data receive "420031****new****2372" 1st called , foundcharacters gets called 2nd time returns remaining string "–2398, nw maynard rd cary north carolina united states2372–2398, nw maynard rd"

but rest records entire string, above data gets break while parsing...

i did sorts of testing, not getting why gets half string. record.

that method not guarantee whole content. apple's documentation:

the parser object may send delegate several parser:foundcharacters: messages report characters of element. because string may part of total character content current element, should append current accumulation of characters until element changes.

your best bet created nsmutablestring , keep appending until delegate receives parser:didendelement call. should start xml parsing guide.


Comments