Parse and traverse HTML in your RubyMotion app. It's like Nokogiri for RubyMotion!
Motion::HTML uses IGHTMLQuery under the hood.
Currently, only iOS is supported.
Add this line to your application's Gemfile:
gem 'motion-html'
And then execute:
$ bundle && rake pod:install
Initialize a new document:
doc = Motion::HTML::Doc.new(html)
# or simply:
doc = Motion::HTML.parse(html)
Then query using css or xpath selectors. It returns an array of nodes:
nodes = doc.query('.photos li a')
Iterate over the results, and use the attributes or content:
nodes.each do |node|
puts "Link text: " + node.text
puts "Link URL: " + node['href']
end
So far, these are the only features that I have needed. Feel free to submit a GitHub issue if you need anything else.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
MIT