开发者

How LibXmlParsing can parse in chunks

开发者 https://www.devze.com 2022-12-09 21:46 出处:网络
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { xmlParseChunk(context, (const char *)[data bytes], [data length], 0);
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    xmlParseChunk(context, (const char *)[data bytes], [data length], 0);
}

my Question is as follows

=> didReceiveData: method receives data in parts

Some what like this

  • first data----------| <masterData>Main</ma
  • second data-----| ster><masterData>Main2
  • third data --------| </masterData>

=> How xmlParseChunk() method can parse all these chunks succ开发者_JAVA百科essfully?


Apple's XMLPerformance sample app illustrates a complete implementation of libxml2 integrated with NSURLConnection and chunk parsing. I found it very helpful.


One approach is to have your delegate contain an NSMutableData member and invoke appendData: when you get new data. Then parse it when your delegate gets the connectionDidFinishLoading message.

0

精彩评论

暂无评论...
验证码 换一张
取 消