From 89689d9bb60e3d34e98882bb843963f855fa17a4 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 4 Sep 2014 00:32:39 +0200 Subject: [PATCH] Basic example for the pull parser. --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index af394c8..2ab2eb4 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,17 @@ Parsing an IO handle pointing to XML (this also works when using Oga.parse_xml(handle) +Parsing an IO handle using the pull parser: + + handle = File.open('path/to/file.xml') + parser = Oga::XML::PullParser.new(handle) + + parser.parse do |node| + parser.on(:text) do + puts node.text + end + end + Querying a document using XPath: document = Oga.parse_xml('Alice')