void () { XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("a.xhtml", XHtmlFileType.INSTANCE, """ <html> <body xmlns:fabrique="https://www.jetbrains.com/schemas/fabrique/page-template"><p> ujhgjhgjhg<table style="width: 82px; height: 84px"><tr><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr></table> jhgjhgjhgjhgjhg</p> </body> </html>"""); XmlTag html = file.getDocument().getRootTag(); XmlTag table = html.findFirstSubTag("body").findFirstSubTag("p").findFirstSubTag("table"); assertEquals("table", table.getName()); WriteCommandAction.runWriteCommandAction(null, () -> table.delete()); assertEquals(""" <html> <body xmlns:fabrique="https://www.jetbrains.com/schemas/fabrique/page-template"><p> ujhgjhgjhg jhgjhgjhgjhgjhg</p> </body> </html>""", file.getText()); }