Adding an Attribute Using JDOM
import org.jdom.Document;
import org.jdom.Element;
public class MainClass {
public static void main(String args[]) {
Document doc = new Document(new Element("games"));
Element newGame = new Element("game").setText("Final Fantasy");
doc.getRootElement().addContent(newGame);
newGame.setAttribute("genre", "rpg");
}
}
Related examples in the same category