Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

HTML/XML parser for RubyMotion, based on GDataXML-HTML

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 vendor
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 wakizashi.gemspec
README.md

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>"
Something went wrong with that request. Please try again.