Basic example for the pull parser.
This commit is contained in:
parent
404ae51fd5
commit
89689d9bb6
11
README.md
11
README.md
|
@ -31,6 +31,17 @@ Parsing an IO handle pointing to XML (this also works when using
|
||||||
|
|
||||||
Oga.parse_xml(handle)
|
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:
|
Querying a document using XPath:
|
||||||
|
|
||||||
document = Oga.parse_xml('<people><person>Alice</person></people>')
|
document = Oga.parse_xml('<people><person>Alice</person></people>')
|
||||||
|
|
Loading…
Reference in New Issue