HTML/XML parser for RubyMotion, based on GDataXML-HTML.
Goal: Nokogiri style interface HTML parsing and building for RubyMotion.
Status: basic search, read and write working
Install the gem
gem install wakizashiAdd the gem to your RubyMotion Rakefile
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
require 'motion-cocoapods'
require 'wakizashi'
Motion::Project::App.setup do |app|
app.name = 'myapp'
# Only needed if you have not already specifying a pods dependency
app.pods do
pod 'GDataXML-HTML'
end
endSearch nodes with XPath
doc = Wakizashi::HTML("<html><body><h1>Hello World</h1><p>Welcome</p><p>Foo</p><a href='http://www.google.com'>Google</a></body></html>")
doc.xpath("//p")Modify nodes
link = doc.xpath("//a").first
link["href"] # => "http://www.google.com"
link["href"] = "http://wikipedia.org"
link.stringValue = "Wiki"
link.to_html => # "<html><body><h1>Hello World</h1><p>Welcome</p><p>Foo</p><a href='http://wikipedia.org'>Wiki</a></body></html>"