Class: ToHashParser

### Home Classes Methods

### In Files

- lib/extlib/hash.rb

### Parent

Object

### Methods

- ::from_xml

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- Extlib
- Extlib::Assertions
- Extlib::ByteArray
- Extlib::Hook
- Extlib::Hook::ClassMethods
- Extlib::Inflection
- Extlib::LocalObjectSpace
- Extlib::Logger
- Extlib::Pooling
- Extlib::Pooling::InvalidResourceError
- Extlib::Pooling::Pool
- Extlib::SimpleSet
- Gem
- Gem::SourceIndex
- Gem::Specification
- LazyModule
- LazyModule::ClassMethods
- Array
- Class
- DateTime
- Dictionary
- FalseClass
- Hash
- LazyArray
- Mash
- Module
- NilClass
- Numeric
- Object
- ObjectSpace
- Pathname
- REXMLUtilityNode
- String
- Struct
- Symbol
- Time
- ToHashParser
- TrueClass
- VirtualFile

No matching classes.

# ToHashParser

### Public Class Methods

from_xml(xml) click to toggle source

    # File lib/extlib/hash.rb, line 427
    def self.from_xml(xml)
      stack = []
      parser = REXML::Parsers::BaseParser.new(xml)

      while true
        event = parser.pull
        case event[0]
        when :end_document
          break
        when :end_doctype, :start_doctype
          # do nothing
        when :start_element
          stack.push REXMLUtilityNode.new(event[1], event[2])
        when :end_element
          if stack.size > 1
            temp = stack.pop
            stack.last.add_node(temp)
          end
        when :text, :cdata
          stack.last.add_node(event[1]) unless event[1].strip.length == 0
        end
      end
      stack.pop.to_hash
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.