PsiElement[] (XmlFile xmlFile) { XmlTag tag = xmlFile.getDocument().getRootTag(); assert tag != null; PsiElement[] answer = new PsiElement[2]; int cnt = 0; for (PsiElement child : tag.getChildren()) { if (child instanceof XmlToken) { IElementType type = ((XmlToken)child).getTokenType(); if (type == XmlTokenType.XML_NAME) { answer[cnt++] = child; } } } return answer; }