public void toXML(String offset, StringBuilder b) { b.append(offset); b.append('<'); b.append(name); for (String key : attributes.keySet()) { b.append(' '); b.append(key); b.append("=\""); b.append(attributes.get(key)); b.append('"'); } if (kids.isEmpty()) { b.append("/>\n"); return; } else { b.append(">\n"); for (Element kid : kids) { kid.toXML(offset + OFFSET, b); } b.append(offset); b.append("</"); b.append(name); b.append(">\n"); } }
public Element getChild(String name) { // boolean search = false; for (Element el : kids) { if (el.getName().equals(name)) return el; } return null; }
public void add(Element e) { kids.add(e); e.parent = this; }