In Files

Parent

Methods

Class Index [+]

Quicksearch

Crack::XML

Public Class Methods

parse(xml) click to toggle source
     # File lib/crack/xml.rb, line 189
189:     def self.parse(xml)
190:       stack = []
191:       parser = REXML::Parsers::BaseParser.new(xml)
192: 
193:       while true
194:         event = parser.pull
195:         case event[0]
196:         when :end_document
197:           break
198:         when :end_doctype, :start_doctype
199:           # do nothing
200:         when :start_element
201:           stack.push REXMLUtilityNode.new(event[1], event[2])
202:         when :end_element
203:           if stack.size > 1
204:             temp = stack.pop
205:             stack.last.add_node(temp)
206:           end
207:         when :text, :cdata
208:           stack.last.add_node(event[1]) unless event[1].strip.length == 0 || stack.empty?
209:         end
210:       end
211:       stack.length > 0 ? stack.pop.to_hash : {}
212:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.