Changeset 1133

Show
Ignore:
Timestamp:
12/25/07 02:32:22 (1 year ago)
Author:
coda.ha..@gmail.com
Message:

Add support for CDATA sections in Hash.from_xml. Closes #320 [daniel.manges@gmail.com]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/merb/core_ext/hash.rb

    r1117 r1133  
    285285                            stack.last.add_node(temp) 
    286286                          end 
    287                         when :text 
     287                        when :text, :cdata 
    288288                          stack.last.add_node(event[1]) unless event[1].strip.length == 0 
    289289                        end 
  • trunk/spec/merb/core_ext_spec.rb

    r1085 r1133  
    224224    xml = "<tag>This is the contents</tag>" 
    225225    Hash.from_xml( xml ).should == { 'tag' => 'This is the contents' } 
     226  end 
     227   
     228  it "should work with cdata tags" do 
     229    xml = <<-END 
     230      <tag> 
     231      <![CDATA[ 
     232        text inside cdata 
     233      ]]> 
     234      </tag> 
     235    END 
     236    Hash.from_xml(xml)["tag"].strip.should == "text inside cdata" 
    226237  end 
    227238