XML Parser module for mruby using Expat that is XML Parser library by C. You can parse XML text from mruby application by using this module.
- add conf.gem line to
build_config.rb
MRuby::Build.new do |conf|
# ... (snip) ...
conf.gem :github => 'bamchoh/mruby-expat'
endroot = XmlParser.parse('
<root>
<nodes counts="3">
<node id="1">a</node>
<node id="2">b</node>
<node id="3">c</node>
</nodes>
</root>')
p root.name #=> "root"
#
# find method for example
#
nodes = root.find("nodes")
p nodes.name #=> "nodes"
p nodes.attributes #=> {"counts" => "3"}
nodes.children.each do |child|
p child.name #=> "node"
end
#
# find_all method for example
#
elems = root.find_all("node")
elems.each do |elem|
p elem.name #=> "node"
p elem.text #=> "a", "b", "c"
end
#
# find method with node and attributes
#
node = root.find("node", {"id"=>"2"})
p node.name #=> "node"
p node.attributes #=> {"id"=>"2"}
p node.text #=> "b"under the MIT License:
- see LICENSE file
