Basic example for the pull parser.

This commit is contained in:
Yorick Peterse committed 2014-09-04 00:32:39 +02:00
1 parent 404ae51fd5
commit 89689d9bb6
1 file changed
+11
+11
View File
@@ -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('<people><person>Alice</person></people>')