--- /dev/null
+#!/usr/bin/perl
+
+# Tests that the following translations take place, and none other:
+#
+# & => & (aka &)
+# < => < (aka <)
+# > => > (aka >)
+# ' => ' (aka ')
+# " => " (aka ")
+#
+# Further tests that already-escaped things are not further escaped.
+#
+# Escapes are defined in the XML spec:
+# http://www.w3.org/TR/2006/REC-xml11-20060816/#dt-escape
+
+
+BEGIN {
+ %translations = (
+ 'x > 3' => 'x > 3',
+ 'x < 3' => 'x < 3',
+ '< 3 >' => '< 3 >',
+ "he's" => "he's",
+ "he’s" => "he’s", # MS "smart" quotes don't get escaped (single)
+ '"his"' => '"his"',
+ '‘his’' => '‘his’', # MS "smart" quotes don't get escaped (single)
+ '“his”' => '“his”', # MS "smart" quotes don't get escaped (double)
+ '1&2' => '1&2',
+ '1&2' => '1&2',
+ '1&2' => '1&2',
+ '1& 2' => '1&amp 2',
+ '1& 2' => '1&#38 2',
+ 'abc' => 'abc',
+ 'número' => 'número',
+ '⇓' => '⇓',
+ 'Œ' => 'Œ',
+ '²' => '²',
+ '&no_go;' => '&no_go;',
+
+ 'This ſoftware has ſome bugs' => 'This ſoftware has ſome bugs', # RT 18568
+ );
+
+ $tests = keys(%translations) + 1;
+}
+
+use Test::More tests => $tests;
+
+BEGIN {
+
+ use_ok('HTML::Element');
+}
+
+foreach my $orig (keys %translations) {
+ $new = $orig;
+ HTML::Element::_xml_escape($new);
+ is($new,$translations{$orig},"Properly escaped: $orig");
+}
+