1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
public static void main(String args[])
{
Element racine = new Element("Frames");
Document document= new Document(racine);
Element frame = XMLFile.addElement("Frame", racine);
Element header= XMLFile.addElement("header", frame);
SetText(header,"tttt");
Element body= XMLFile.addElement("body", frame);
SetText(body,"bbbbb");
XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
sortie.output(document, new FileOutputStream("frames"));
}
public static Element addElement(String field, Element elementName)
{
Element fieldName = new Element(field);
elementName.addContent(fieldName);
return fieldName;
}
public static void SetText(Element elementName, String text)
{
elementName.setText(text);
} |
Partager