Module: Ruote::XmlReader
- Defined in:
- lib/ruote/reader/xml.rb
Overview
Turns an XML string into a process definition tree.
Defined Under Namespace
Classes: Node
Class Method Summary (collapse)
-
+ (Object) read(s)
Parses the XML string into a process definition tree (array of arrays).
Class Method Details
+ (Object) read(s)
Parses the XML string into a process definition tree (array of arrays).
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/ruote/reader/xml.rb', line 65 def self.read(s) parser = REXML::Parsers::SAX2Parser.new(s) root = nil current = nil # u, l, q, a <=> url, local, qname, attributes parser.listen(:start_element) do |u, l, q, a| current = Node.new(current, l.gsub(/-/, '_'), a) root ||= current end parser.listen(:end_element) do |u, l, q, a| current = current.parent end parser.listen(:characters) do |text| t = text.strip current.attributes[t] = nil if t.size > 0 end parser.parse root.to_a end |