1

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

Phil C
  • 3,561
  • 3
  • 25
  • 46
SRI
  • 1,464
  • 20
  • 36

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,133
  • 1
  • 17
  • 37