1

I need to parse an html so any one tell me how to do this in objective-c?

Phil C
  • 3,687
  • 4
  • 29
  • 51
SRI
  • 1,514
  • 21
  • 39

1 Answers1

1

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")
iska
  • 2,208
  • 1
  • 18
  • 37