diff --git a/mode/xml/xml.js b/mode/xml/xml.js
index 3ab55f75d44abc4ad226888c9d9ec724b6e618f7..4f49e07faf5e45c7dbf4eaf736c9d798348b3ac2 100644
--- a/mode/xml/xml.js
+++ b/mode/xml/xml.js
@@ -109,8 +109,9 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
       type = "equals";
       return null;
     } else if (ch == "<") {
-      stream.match(/^\/?\w*\/?>/);
-      return "tag error";
+      state.tokenize = inText;
+      var next = state.tokenize(stream, state);
+      return next ? next + " error" : "error";
     } else if (/[\'\"]/.test(ch)) {
       state.tokenize = inAttribute(ch);
       state.stringStartCol = stream.column();