I am making an API kind of thing for school for a custom XML writer. I have:
public Document CreateDocument(int loops, int attr, String data[], String dataattr[][][]) {
Document BetterDoc = DocumentHelper.createDocument();
Element root = BetterDoc.addElement("root");
for (int i = 0; i < loops; i++) {
Element(Object) data[i] = root.addElement(data[i])
for (int i2 = 0; i < attr; i++) {
.addAtribute(dataattr[i][i2][0], dataattr[i][i2][1])
};
}
return BetterDoc;
}
The line that I want help with is:
Element(Object) data[i] = root.addElement(data[i])
I want to create an element with the same name of the data[i].
I am using the dom4j XML .jar in this, by the way.
I have heard of something called a hashmap and if this is the correct method, would someone please explain how to use it.