Why element creation requires the document object in DOM?
Posted
by maayank
on Stack Overflow
See other posts from Stack Overflow
or by maayank
Published on 2010-04-04T11:01:08Z
Indexed on
2010/04/04
11:03 UTC
Read the original article
Hit count: 261
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?
© Stack Overflow or respective owner