xml类
- Element
- XmlElement extends Element
- Attribute
- Document
private List<Attribute> attributes;
private List<Element> elements;
private String name;
public String getFormattedContent(int indentLevel) {
StringBuilder sb = new StringBuilder();
OutputUtilities.xmlIndent(sb, indentLevel);
sb.append('<');
sb.append(name);
Collections.sort(attributes);
for (Attribute att : attributes) {
sb.append(' ');
sb.append(att.getFormattedContent());
}
if (elements.size() > 0) {
sb.append(">");
for (Element element : elements) {
OutputUtilities.newLine(sb);
sb.append(element.getFormattedContent(indentLevel + 1));
}
OutputUtilities.newLine(sb);
OutputUtilities.xmlIndent(sb, indentLevel);
sb.append("</");
sb.append(name);
sb.append('>');
} else {
sb.append(" />");
}
return sb.toString();
}
private String name;
private String value;