diff --git a/vlib/encoding/xml/parser.v b/vlib/encoding/xml/parser.v
index 86dbc6594cd69d..9a52d1d31db18a 100644
--- a/vlib/encoding/xml/parser.v
+++ b/vlib/encoding/xml/parser.v
@@ -562,7 +562,7 @@ pub fn parse_single_node(first_char u8, mut reader io.Reader) !XMLNode {
tag_contents := contents.str().trim_space()
parts := tag_contents.split_any(' \t\n')
- name := parts[0]
+ name := parts[0].trim_right('/')
// Check if it is a self-closing tag
if tag_contents.ends_with('/') {
diff --git a/vlib/encoding/xml/parser_test.v b/vlib/encoding/xml/parser_test.v
index 3de74829b2e857..368534d9751aa8 100644
--- a/vlib/encoding/xml/parser_test.v
+++ b/vlib/encoding/xml/parser_test.v
@@ -7,6 +7,7 @@ const (
Sample Text
+
@@ -34,6 +35,10 @@ const (
'Sample Text',
]
},
+ XMLNode{
+ name: 'empty'
+ attributes: {}
+ },
XMLNode{
name: 'c'
attributes: {