README.md in sax-machine-0.3.0 vs README.md in sax-machine-1.0.0
- old
+ new
@@ -26,34 +26,30 @@
$ bundle
```
## Usage
-To use **Nokogiri** as a SAX handler:
+SAX Machine can use either `nokogiri` or `ox` as XML SAX handler.
+To use **Nokogiri** add this line to your Gemfile:
+
```ruby
-require 'sax-machine'
+gem 'nokogiri', '~> 1.6'
```
-To use **Ox** as a SAX handler:
+To use **Ox** add this line to your Gemfile:
-Add this line to your application's Gemfile:
-
```ruby
gem 'ox', '>= 2.1.2'
```
-Tell SAXMachine to use Ox:
+You can also specify which handler to use manually, like this:
```ruby
-require 'sax-machine'
-SAXMachine.handler = :ox
+SAXMachine.handler = :nokogiri
```
-Please note that this operation is not thread-safe, so it's better to define
-handler at initialization stage and do not change it during runtime.
-
## Examples
Include `SAXMachine` in any class and define properties to parse:
```ruby
@@ -67,11 +63,12 @@
include SAXMachine
element :title
# The :as argument makes this available through entry.author instead of .name
element :name, as: :author
element "feedburner:origLink", as: :url
- element :summary
+ # The :default argument specifies default value for element when it's missing
+ element :summary, class: String, default: "No summary available"
element :content, class: AtomContent
element :published
ancestor :ancestor
end
@@ -102,9 +99,10 @@
feed.feed_url # The URL of the blog feed
feed.entries.first.title # Title of the first entry
feed.entries.first.author # The author of the first entry
feed.entries.first.url # Permalink on the blog for this entry
+feed.entries.first.summary # Returns "No summary available" if summary is missing
feed.entries.first.ancestor # The Atom ancestor
feed.entries.first.content # Instance of AtomContent
feed.entries.first.content.text # Entry content text
```