I need to parse an html so any one tell me how to do this in objective-c?
Asked
Active
Viewed 6,714 times
1
-
What is your target: Mac OS or iOS? – Feb 23 '11 at 09:45
1 Answers
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