W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2000

Re: A quick question

From: Eric Richardson <maxwell@telesoft.com>
Date: Fri, 26 May 2000 07:46:41 -0700
Message-ID: <392E8E51.CF8EE439@telesoft.com>
To: DOM <www-dom@w3.org>
Philippe Le Hegaret wrote:

> The load and save module is part of DOM Level 3 and is not in DOM Level
> 2. For the moment, the implementations have their own API for the
> serialization. Check their documentation.
>
> Philippe
>
> Mark Torr wrote:
> >
> > I am using the DOM via a Java Server Page and need to render my output. I
> > currently have the following code:
> >
> > <html>
> > <body>
> > <%@ page import="javax.xml.parsers.*"%>
> > <%@ page import="org.w3c.dom.*" %>
> > <%
> >    try {
> >       DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
> >       DocumentBuilder db = dbf.newDocumentBuilder ();
> >       Document doc = db.newDocument ();
> >       Element root = doc.createElement ("mytest");
> >       doc.appendChild (root);
> >       root.appendChild (doc.createElement ("header"));
> >       root.appendChild (doc.createTextNode ("\n  some data is text\n  "));
> >       root.appendChild (doc.createElement ("footer"));
> >     } catch (Exception e) {}
> > %>
> > </body>
> > </html>
> >
> > Can someone tell me how to get the document to write itself out? Or do I
> > have to go through the whole tree myself?

Hi Mark,
In a non-portable way you can cast the Document to XmlDocument and use the
non-portable
write methods. This assumes you are using xml-tr2 as your underlying DOM.
eric :-)
Received on Friday, 26 May 2000 10:50:33 GMT

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