Hallo,
habe ein kleines Problem. Ich möchte eine XML datei erstellen.
Beim ausführen bekomme ich die Meldung: The Content already has an existing parent "root"
Der Code(bis jetzt nur ein Testbeispiel) sieht so aus:
Wie bekomme ich mehrere Elemente unter root hin?
habe ein kleines Problem. Ich möchte eine XML datei erstellen.
Beim ausführen bekomme ich die Meldung: The Content already has an existing parent "root"
Der Code(bis jetzt nur ein Testbeispiel) sieht so aus:
Code:
Element root = new Element("root");
Document myDocument = new Document(root);
Element carElement = new Element("car");
root.addContent(carElement);
Element make = new Element("make");
make.addContent("Toyota");
carElement.addContent(make);
Element model = new Element("model");
model.addContent("Celica");
carElement.addContent(model);
//bis hierhin funktioniert es!
root.addContent(carElement);
make.addContent("Nissan");
carElement.addContent(make);
model.addContent("Primera");
carElement.addContent(model);
Wie bekomme ich mehrere Elemente unter root hin?