diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc
index c97d58bcf2..196720885d 100644
--- a/CHANGELOG.rdoc
+++ b/CHANGELOG.rdoc
@@ -23,6 +23,7 @@
* JRuby 1.9 mode causes dead lock while running rake #571
* HTML::Document#meta_encoding does not raise exception on docs with
malformed content-type. #655
+ * Nokogiri::XML::Text#to_ary returns an array with the node text. #679
== 1.5.2 / 2012-03-09
diff --git a/lib/nokogiri/xml/text.rb b/lib/nokogiri/xml/text.rb
index 99eecb1bff..5ab96f9530 100644
--- a/lib/nokogiri/xml/text.rb
+++ b/lib/nokogiri/xml/text.rb
@@ -4,6 +4,10 @@ class Text < Nokogiri::XML::CharacterData
def content=(string)
self.native_content = string.to_s
end
+
+ def to_ary
+ [self.text]
+ end
end
end
end
diff --git a/test/xml/test_text.rb b/test/xml/test_text.rb
index 14f1d911f9..d043ad6251 100644
--- a/test/xml/test_text.rb
+++ b/test/xml/test_text.rb
@@ -3,6 +3,12 @@
module Nokogiri
module XML
class TestText < Nokogiri::TestCase
+ def test_ary
+ doc = Nokogiri.XML " foo something bar bazz "
+ node = doc.root.children[2]
+ assert_equal [node.text], Array(node)
+ end
+
def test_css_path
doc = Nokogiri.XML " foo something bar bazz "
node = doc.root.children[2]