DOM - Creating Documents

Jeff Greif jmg at trivida.com
Thu Apr 22 18:12:07 BST 1999


Snarfed from the very useful guide.html that came with the IBM xml4j
(version 1.1.9) distribution
(the documentation has changed in later versions, and I haven't looked for
the replacement.):

<Quotation>
Creating a new XML document is a three step process. First, create the
TXDocument, which is the concrete implementation of Document. Second, create
the various XML objects using the TXDocument's create* methods. Finally, use
appendChild to append these appropriately to the TXDocument or sub-Elements.
Make a TXDocument instance.

TXDocument doc = new TXDocument();


 Create something, a DTD or root Element.
        Element root = doc.createElement("ROOT"));

Append  the newly created Element.
        doc.appendChild(root);

Append something to the root Element you have added.

      root.appendChild(doc.createElement("FOO"));
</Quotation>



----- Original Message -----
From: Ronald Bourret <rbourret at ito.tu-darmstadt.de>
To: 'XML-DEV' <xml-dev at ic.ac.uk>
Sent: Thursday, April 22, 1999 4:55 AM
Subject: Re: DOM - Creating Documents


>
> 2) Is it really not possible to create a new Document with IBM's classes?
>  I can't find a method for doing it.
>



xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list