xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arnaud Le Hors <leh...@us.ibm.com>
Subject Re: Another question about using Xerces
Date Wed, 01 Mar 2000 18:02:08 GMT
As defined in the spec [1] createDocument() not only create the Document
node but also the root element (also called "document element"). So you
need to start adding elements to the root element and not to the
Document itself. Try:

 public XercesTest() {
    DOMImplementationImpl imp = new DOMImplementationImpl();
    Document doc = imp.createDocument(null, "Test", null);
    Element e = doc.createElement("dummElement");
    doc.getDocumentElement().appendChild(e);
  }

Since a Document can only have one element child, trying to add any
other raises an exception.

[1]
http://www.w3.org/TR/1999/CR-DOM-Level-2-19991210/core.html#Level-2-Core-DOM-createDocument
-- 
Arnaud  Le Hors - IBM Cupertino, XML Technology Group

Mime
View raw message