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>
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
names (#PCDATA)* so I can add many names.

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

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.

Received on Friday, 3 March 2000 12:42:53 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:06 UTC