void () { final XmlTag rootTag = XmlElementFactory.getInstance(getProject()).createTagFromText("<html/>"); WriteCommandAction.runWriteCommandAction(null, () -> { rootTag.setAttribute("foo", "bar"); }); assertEquals(1, rootTag.getAttributes().length); assertEquals("bar", rootTag.getAttributeValue("foo")); assertEquals("foo", rootTag.getAttributes()[0].getName()); assertEquals("<html foo=\"bar\"/>", rootTag.getText()); }