diff --git a/src/tree-view/xml-tree-data-provider.ts b/src/tree-view/xml-tree-data-provider.ts index 1cce499..f79205e 100644 --- a/src/tree-view/xml-tree-data-provider.ts +++ b/src/tree-view/xml-tree-data-provider.ts @@ -215,7 +215,11 @@ export class XmlTreeDataProvider implements TreeDataProvider { const xml = this.activeEditor.document.getText(); try { - this._xmlDocument = new DOMParser().parseFromString(xml, "text/xml"); + this._xmlDocument = new DOMParser({ + errorHandler: () => { + throw new Error("Invalid Document"); + } + }).parseFromString(xml, "text/xml"); } catch {