Project

wakizashi

0.01
No commit activity in last 3 years
No release in over 3 years
HTML/XML parser for RubyMotion, based on GDataXML-HTML.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

wakizashi - HTML/XML Parser for RubyMoton

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

Install the gem

gem install wakizashi

Add 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
end

Usage

Parsing

Search 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>"