if (node instanceof Element) {
arg = ((Element) node).getName();
} else if (node instanceof Attribute) {
arg = ((Attribute) node).getName();
} else if (node instanceof CDATA) {
CDATA cDATA = (CDATA) node;
arg = cDATA.getParent().getName();
} else if (node instanceof Text) {
Text text = (Text) node;
arg = text.getParent().getName();
} else {
// this should never happen as the XPath should always refer to