String text;
if (node instanceof Element) {
Element element = (Element)node;
text = "<" + element.getName() + ">";
} else if (node instanceof TextNode) {
TextNode textNode = (TextNode)node;
text = textNode.getText();
if (text.length() > MAXIMUM_TEXT_LENGTH) {
text = "\"" + text.substring(0, MAXIMUM_TEXT_LENGTH) + "\"...";
} else {
text = "\"" + text + "\"";