How to parse a web page source to get the values for an array
I am trying to implement a lotto game on the ipod and i need 开发者_如何学Pythonto parse the actual lotto page to get the winning numbers and to put them in an array to compare them with the numbers that the user had entered and find out if he is a winner or not. Can anyone help me with it because really am stuck with it?
Thanks in advance! :)
What you need is a DOM parser, such as Apple's NSXMLParser.
Specifically you'd want to use XPath parsing to read the value of a specific DOM node on your lotto page's DOM tree.
As iOS does not come with NSXMLDocument (which supports XPath), you'd probably need to do as described here:
Using libxml2 for XML parsing and XPath queries in Cocoa
Other solutions for parsing XML/HTML:
How To Choose The Best XML Parser for Your iPhone Project
精彩评论