xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "HERRICK, CHUCK (SBCSI)" <CH6...@momail.sbc.com>
Subject RE: Another question about using Xerces
Date Wed, 01 Mar 2000 19:33:46 GMT
I think he could have written
--
>     Element e = doc.createElement("dummElement");
>     doc.getDocumentElement().appendChild(e);
--
as easily
--
>     Element e = doc.createElement("dummElement");
>     e.appendChild(e);
--
I believe doc.getDocumentElement() get's the root
Element of a Document, to which you would then
appendChild().

I'm no XML'spert, just an XMLaholic, so correct me
if I'm wrong, please.

-----Original Message-----
From: Eric Hodges [mailto:harmony2@swbell.net]
Sent: Wednesday, March 01, 2000 1:33 PM
To: general@xml.apache.org
Subject: Re: Another question about using Xerces


Ah, thanks.  I've never seen that spec before, and I've been to W3.org many
times.

Does anyone know why Document has an appendChild method if it can't have
children?  Is it just a bad interface hierarchy?


----- Original Message -----
From: Arnaud Le Hors <lehors@us.ibm.com>
To: <general@xml.apache.org>
Sent: Wednesday, March 01, 2000 12:02 PM
Subject: Re: Another question about using Xerces


> 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