void () { final XmlTag rootTag = XmlElementFactory.getInstance(getProject()).createTagFromText("<html>aaa</html>"); final XmlText xmlText = rootTag.getValue().getTextElements()[0]; WriteCommandAction.runWriteCommandAction(null, () -> xmlText.removeText(1, 2)); assertEquals(1, xmlText.getChildren().length); assertEquals("<html>aa</html>", rootTag.getText()); }