Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
iOS Development
XML Parsing Done Wrong?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Mark FX" data-source="post: 1404098" data-attributes="member: 211556"><p>Your code is a little confusing as your using iVars that we cant see in the posted code.</p><p>Also you have'nt implemented all of the NSURLConnection delegate methods, or all of the</p><p>NSXMLParser delegate methods either.</p><p></p><p>[CODE] - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error[/CODE]</p><p></p><p>This method is very important, to catch errors if the connection fails, or is interrupted.</p><p></p><p>But I also noticed that you are not calling the parse method of the NSXMLParser, like this.</p><p></p><p>[CODE]</p><p>NSMutableData *xmlData;</p><p></p><p>NSXMLParser *parser = [[NSXMLParser alloc] initWithData: xmlData];</p><p></p><p>[parser setDelegate: self];</p><p></p><p>[parser parse]; //You have to make this method call to start the data parsing</p><p></p><p>[parser release]; //You can release the parser straight away as it blocks until finished</p><p>[/CODE]</p><p></p><p>Also make sure you implement all of the NSXMLParser delegate XML methods, even if you dont want to use them, and simply put NSLog statements in each method to check the data flow.</p><p></p><p><a href="https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/NSXMLParserDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008632" target="_blank">https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/NSXMLParserDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008632</a></p><p></p><p>Also do the same thing with the NSURLConnection delegate methods.</p><p></p><p><a href="https://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40009947" target="_blank">https://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40009947</a></p><p></p><p>Good luck with it.</p><p></p><p>Regards Mark</p></blockquote><p></p>
[QUOTE="Mark FX, post: 1404098, member: 211556"] Your code is a little confusing as your using iVars that we cant see in the posted code. Also you have'nt implemented all of the NSURLConnection delegate methods, or all of the NSXMLParser delegate methods either. [CODE] - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error[/CODE] This method is very important, to catch errors if the connection fails, or is interrupted. But I also noticed that you are not calling the parse method of the NSXMLParser, like this. [CODE] NSMutableData *xmlData; NSXMLParser *parser = [[NSXMLParser alloc] initWithData: xmlData]; [parser setDelegate: self]; [parser parse]; //You have to make this method call to start the data parsing [parser release]; //You can release the parser straight away as it blocks until finished [/CODE] Also make sure you implement all of the NSXMLParser delegate XML methods, even if you dont want to use them, and simply put NSLog statements in each method to check the data flow. [URL="https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/NSXMLParserDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008632"]https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/NSXMLParserDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008632[/URL] Also do the same thing with the NSURLConnection delegate methods. [URL="https://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40009947"]https://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40009947[/URL] Good luck with it. Regards Mark [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
iOS Development
XML Parsing Done Wrong?
Top