W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2000

Adding Content to DOM

From: Eric Richardson <maxwell@telesoft.com>
Date: Fri, 03 Mar 2000 10:40:36 -0700
Message-ID: <38BFF914.C57E82B1@telesoft.com>
To: DOM <www-dom@w3.org>
Hi,
I have a beginner question.
I create a DTD and read a document in that conforms to the DTD. The
content model
allows me to add a names element like this.

Element element = doc.createElement("names");

and then add text nodes to that element

 element.appendChild(doc.createTextNode ("Eric Richardson"));
root.appendChild(element); // add the element

In this model names is optional (names?) so I can read the doc in
without it using strict parsing
but then add a names element. Then I can add many text nodes to my names
tag,
names (#PCDATA)* so I can add many names.

<mydoc>
  <some-tag />
  <names>
  Eric Richardson
  other names ...
</names>
</mydoc>

Is there a simple way to make sure that the document is valid when I add
elements to it in memory?
Hopefully in a portable way.

Thanks
Eric
Received on Friday, 3 March 2000 12:42:53 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:47 GMT