@Override public void visitTag(Tag tag) { Element e = Document.get().createElement(tag.getTagName()); map.put(tag, e); for (Object o : tag.getAttributesEx()) { Attribute a = (Attribute) o; if ("id".equalsIgnoreCase(a.getName())) { e.setId(a.getValue()); } else if ("style".equalsIgnoreCase(a.getName())) { processStyle(e, a.getValue()); } else if ("class".equalsIgnoreCase(a.getName())) { e.setClassName(a.getValue()); } else if (!a.isEmpty() && !a.isWhitespace() && a.isValued()) { e.setAttribute(a.getName(), a.getValue()); } } Element parent = getParent(tag.getParent()); parent.appendChild(e); }