As noted by others, in Java, with the default W3C DOM libraries, one is required to use the Document object a factory to elements, i.e.:
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Document d;
Element e;
e = d.createElement("tag");
Why is that necessary? Why conceptually a method can't create an XML element without knowing all of the target document? Why I can't just instantiate using 'new' or something to that effect?