<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -78,3 +78,215 @@ class String
     strip.empty?
   end
 end # class String
+
+require 'rexml/parsers/streamparser'
+require 'rexml/parsers/baseparser'
+require 'rexml/light/node'
+
+# This is a slighly modified version of the XMLUtilityNode from
+# http://merb.devjavu.com/projects/merb/ticket/95 (has.sox@gmail.com)
+# It's mainly just adding vowels, as I ht cd wth n vwls :)
+# This represents the hard part of the work, all I did was change the
+# underlying parser.
+class REXMLUtilityNode
+  attr_accessor :name, :attributes, :children, :type
+  
+  def self.typecasts
+    @@typecasts
+  end
+  
+  def self.typecasts=(obj)
+    @@typecasts = obj
+  end
+  
+  def self.available_typecasts
+    @@typecasts
+  end
+  
+  def self.available_typecasts=(obj)
+    @@typecasts = obj
+  end
+
+  self.typecasts = {}
+  self.typecasts[&quot;integer&quot;]       = lambda{|v| v.nil? ? nil : v.to_i}
+  self.typecasts[&quot;boolean&quot;]       = lambda{|v| v.nil? ? nil : (v.strip != &quot;false&quot;)}
+  self.typecasts[&quot;datetime&quot;]      = lambda{|v| v.nil? ? nil : Time.parse(v).utc}
+  self.typecasts[&quot;date&quot;]          = lambda{|v| v.nil? ? nil : Date.parse(v)}
+  self.typecasts[&quot;dateTime&quot;]      = lambda{|v| v.nil? ? nil : Time.parse(v).utc}
+  self.typecasts[&quot;decimal&quot;]       = lambda{|v| BigDecimal(v)}
+  self.typecasts[&quot;double&quot;]        = lambda{|v| v.nil? ? nil : v.to_f}
+  self.typecasts[&quot;float&quot;]         = lambda{|v| v.nil? ? nil : v.to_f}
+  self.typecasts[&quot;symbol&quot;]        = lambda{|v| v.to_sym}
+  self.typecasts[&quot;string&quot;]        = lambda{|v| v.to_s}
+  self.typecasts[&quot;yaml&quot;]          = lambda{|v| v.nil? ? nil : YAML.load(v)}
+  self.typecasts[&quot;base64Binary&quot;]  = lambda{|v| v.unpack('m').first }
+
+  self.available_typecasts = self.typecasts.keys
+
+  def initialize(name, attributes = {})
+    @name         = name.tr(&quot;-&quot;, &quot;_&quot;)
+    # leave the type alone if we don't know what it is
+    @type         = self.class.available_typecasts.include?(attributes[&quot;type&quot;]) ? attributes.delete(&quot;type&quot;) : attributes[&quot;type&quot;]
+
+    @nil_element  = attributes.delete(&quot;nil&quot;) == &quot;true&quot;
+    @attributes   = undasherize_keys(attributes)
+    @children     = []
+    @text         = false
+  end
+
+  def add_node(node)
+    @text = true if node.is_a? String
+    @children &lt;&lt; node
+  end
+
+  def to_hash
+    if @type == &quot;file&quot;
+      f = StringIO.new((@children.first || '').unpack('m').first)
+      class &lt;&lt; f
+        attr_accessor :original_filename, :content_type
+      end
+      f.original_filename = attributes['name'] || 'untitled'
+      f.content_type = attributes['content_type'] || 'application/octet-stream'
+      return {name =&gt; f}
+    end
+
+    if @text
+      return { name =&gt; typecast_value( translate_xml_entities( inner_html ) ) }
+    else
+      #change repeating groups into an array
+      groups = @children.inject({}) { |s,e| (s[e.name] ||= []) &lt;&lt; e; s }
+
+      out = nil
+      if @type == &quot;array&quot;
+        out = []
+        groups.each do |k, v|
+          if v.size == 1
+            out &lt;&lt; v.first.to_hash.entries.first.last
+          else
+            out &lt;&lt; v.map{|e| e.to_hash[k]}
+          end
+        end
+        out = out.flatten
+
+      else # If Hash
+        out = {}
+        groups.each do |k,v|
+          if v.size == 1
+            out.merge!(v.first)
+          else
+            out.merge!( k =&gt; v.map{|e| e.to_hash[k]})
+          end
+        end
+        out.merge! attributes unless attributes.empty?
+        out = out.empty? ? nil : out
+      end
+
+      if @type &amp;&amp; out.nil?
+        { name =&gt; typecast_value(out) }
+      else
+        { name =&gt; out }
+      end
+    end
+  end
+
+  # Typecasts a value based upon its type. For instance, if
+  # +node+ has #type == &quot;integer&quot;,
+  # {{[node.typecast_value(&quot;12&quot;) #=&gt; 12]}}
+  #
+  # @param value&lt;String&gt; The value that is being typecast.
+  #
+  # @details [:type options]
+  #   &quot;integer&quot;::
+  #     converts +value+ to an integer with #to_i
+  #   &quot;boolean&quot;::
+  #     checks whether +value+, after removing spaces, is the literal
+  #     &quot;true&quot;
+  #   &quot;datetime&quot;::
+  #     Parses +value+ using Time.parse, and returns a UTC Time
+  #   &quot;date&quot;::
+  #     Parses +value+ using Date.parse
+  #
+  # @return &lt;Integer, TrueClass, FalseClass, Time, Date, Object&gt;
+  #   The result of typecasting +value+.
+  #
+  # @note
+  #   If +self+ does not have a &quot;type&quot; key, or if it's not one of the
+  #   options specified above, the raw +value+ will be returned.
+  def typecast_value(value)
+    return value unless @type
+    proc = self.class.typecasts[@type]
+    proc.nil? ? value : proc.call(value)
+  end
+
+  # Convert basic XML entities into their literal values.
+  #
+  # @param value&lt;#gsub&gt; An XML fragment.
+  #
+  # @return &lt;#gsub&gt; The XML fragment after converting entities.
+  def translate_xml_entities(value)
+    value.gsub(/&amp;lt;/,   &quot;&lt;&quot;).
+          gsub(/&amp;gt;/,   &quot;&gt;&quot;).
+          gsub(/&amp;quot;/, '&quot;').
+          gsub(/&amp;apos;/, &quot;'&quot;).
+          gsub(/&amp;amp;/,  &quot;&amp;&quot;)
+  end
+
+  # Take keys of the form foo-bar and convert them to foo_bar
+  def undasherize_keys(params)
+    params.keys.each do |key, value|
+      params[key.tr(&quot;-&quot;, &quot;_&quot;)] = params.delete(key)
+    end
+    params
+  end
+
+  # Get the inner_html of the REXML node.
+  def inner_html
+    @children.join
+  end
+
+  # Converts the node into a readable HTML node.
+  #
+  # @return &lt;String&gt; The HTML node in text form.
+  def to_html
+    attributes.merge!(:type =&gt; @type ) if @type
+    &quot;&lt;#{name}#{attributes.to_xml_attributes}&gt;#{@nil_element ? '' : inner_html}&lt;/#{name}&gt;&quot;
+  end
+
+  # @alias #to_html #to_s
+  def to_s
+    to_html
+  end
+end
+
+class ToHashParser
+  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 &gt; 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
+end
+
+class Hash
+  def self.from_xml(xml)
+    ToHashParser.from_xml(xml)
+  end
+end
\ No newline at end of file</diff>
      <filename>lib/core_extensions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,7 @@ require 'net/https'
 require 'rubygems'
 gem 'json', '&gt;= 1.1.3'
 require 'json'
+
 require 'module_level_inheritable_attributes'
 require 'core_extensions'
 
@@ -98,5 +99,4 @@ module HTTParty
 end
 
 require 'httparty/exceptions'
-require 'httparty/request'
-require 'httparty/xml'
\ No newline at end of file
+require 'httparty/request'
\ No newline at end of file</diff>
      <filename>lib/httparty.rb</filename>
    </modified>
    <modified>
      <diff>@@ -107,7 +107,7 @@ module HTTParty
         return nil if body.nil? or body.empty?
         case format
         when :xml
-          ToHashParser.from_xml(body)
+          Hash.from_xml(body)
         when :json
           JSON.parse(body)
         else</diff>
      <filename>lib/httparty/request.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/httparty/xml.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>8a70a8ef40531def06c950bfb4902abc774b5b31</id>
    </parent>
  </parents>
  <author>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </author>
  <url>http://github.com/jnunemaker/httparty/commit/7fab301eb592353311a064c76e93c2363f8b7658</url>
  <id>7fab301eb592353311a064c76e93c2363f8b7658</id>
  <committed-date>2008-12-06T19:51:18-08:00</committed-date>
  <authored-date>2008-12-06T19:51:18-08:00</authored-date>
  <message>Moved xml stuff into core extensions where it should be for now.</message>
  <tree>747b16ec92b450b775f1ea64aab98f8931b16a91</tree>
  <committer>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </committer>
</commit>
