I need to parse an html so any one tell me how to do this in objective-c?
Try HTMLKit. It is a pure Objective-C HTML parser with CSS3 Selectors support. It is not a wrapper around libxml or any other library, but rather a complete WHATWG HTML specification-compliant implementation.
Here are some examples in Swift:
let htmlString = "<div><h1>HTMLKit</h1><p>Hello there!</p></div>"
let document = HTMLDocument(string: htmlString)
let stuff = HTMLElement(tagName:"ul", attributes: ["class": "list"])
stuff.innerHTML = "<li>item 1<li>item 2"
let body = document.body!
body.appendNode(stuff)
let items = document.querySelectorAll(".list li")
精彩评论