diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go
index a1e63ed30d3..582cfee222b 100644
--- a/src/encoding/xml/xml.go
+++ b/src/encoding/xml/xml.go
@@ -493,8 +493,12 @@ func (d *Decoder) popElement(t *EndElement) bool {
d.err = d.syntaxError("element <" + s.name.Local + "> closed by " + name.Local + ">")
return false
case s.name.Space != name.Space:
+ ns := name.Space
+ if name.Space == "" {
+ ns = `""`
+ }
d.err = d.syntaxError("element <" + s.name.Local + "> in space " + s.name.Space +
- " closed by " + name.Local + "> in space " + name.Space)
+ " closed by " + name.Local + "> in space " + ns)
return false
}
diff --git a/src/encoding/xml/xml_test.go b/src/encoding/xml/xml_test.go
index 2c985f7c70f..c3848c38730 100644
--- a/src/encoding/xml/xml_test.go
+++ b/src/encoding/xml/xml_test.go
@@ -1346,6 +1346,8 @@ func TestParseErrors(t *testing.T) {
{withDefaultHeader(``), `invalid sequence `), `invalid sequence `), `invalid baz`),
+ `element in space zzz closed by in space ""`},
{withDefaultHeader("\xf1"), `invalid UTF-8`},
// Header-related errors.
@@ -1379,7 +1381,7 @@ func TestParseErrors(t *testing.T) {
continue
}
if !strings.Contains(err.Error(), test.err) {
- t.Errorf("parse %s: can't find %q error sudbstring\nerror: %q", test.src, test.err, err)
+ t.Errorf("parse %s: can't find %q error substring\nerror: %q", test.src, test.err, err)
continue
}
}