void () { @Language("XML") String xml = "<div>&amp;abc</div>"; XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("foo.xml", XmlFileType.INSTANCE, xml); XmlTag root = file.getDocument().getRootTag(); final XmlText text = root.getValue().getTextElements()[0]; assertEquals("&abc", text.getValue()); assertEquals(0, text.displayToPhysical(0)); assertEquals(5, text.displayToPhysical(1)); assertEquals(6, text.displayToPhysical(2)); assertEquals(7, text.displayToPhysical(3)); assertEquals(8, text.displayToPhysical(4)); }