Skip to content

Commit

Permalink
Allow Nokogiri XmlMini backend to process cdata elements
Browse files Browse the repository at this point in the history
[#3219 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
Developer authored and jeremy committed Sep 17, 2009
1 parent 23e72d4 commit 0d76264
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/xml_mini/nokogiri.rb
Expand Up @@ -44,7 +44,7 @@ def to_hash(hash = {})
walker = lambda { |memo, parent, child, callback|
next if child.blank? && 'file' != parent['type']

if child.text?
if child.text? || child.cdata?
(memo[CONTENT_ROOT] ||= '') << child.content
next
end
Expand Down
11 changes: 11 additions & 0 deletions activesupport/test/xml_mini/nokogiri_engine_test.rb
Expand Up @@ -159,6 +159,17 @@ def test_parse_from_io
XmlMini.parse(io)
end

def test_children_with_cdata
assert_equal_rexml(<<-eoxml)
<root>
<products>
hello <![CDATA[everyone]]>
morning
</products>
</root>
eoxml
end

private
def assert_equal_rexml(xml)
hash = XmlMini.with_backend('REXML') { XmlMini.parse(xml) }
Expand Down

0 comments on commit 0d76264

Please sign in to comment.