From f88df486bac076b0a1abeb3cfd544dbb8f2e6d2b Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 17 Nov 2014 23:59:30 +0100 Subject: [PATCH] README example on using Enumerator for input. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 70243c5..c966abb 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,16 @@ Parsing an IO handle using the pull parser: end end +Using an Enumerator to download and parse an XML document on the fly: + + enum = Enumerator.new do |yielder| + HTTPClient.get('http://some-website.com/some-big-file.xml') do |chunk| + yielder << chunk + end + end + + document = Oga.parse_xml(enum) + Parse a string of XML using the SAX parser: class ElementNames