You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Matthew Oatham <ma...@hotmail.com> on 2003/04/14 16:57:47 UTC

creating DOM from file

Hi,

When I create a DOM from an existing file the resulting xml has the following elements missing

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>

I am using DocumentBuilder.parse(File file) to load the DOM tree. Is there a way to retain or add these elements?

Regards.

Matt



RE: creating DOM from file

Posted by Rahul Srivastava <rs...@firstam.com>.
When creating a DOM from a stream, the information such as encoding,
standalone, version, in the XML declaration is not retained by DOM L2, but,
DOM L3 does. The DOCTYPE can be retrieved using the getDoctype() method of
the Document object.

-Rahul.
  -----Original Message-----
  From: Matthew Oatham [mailto:matthewoatham@hotmail.com]
  Sent: Monday, April 14, 2003 8:28 PM
  To: general@xml.apache.org
  Subject: creating DOM from file


  Hi,

  When I create a DOM from an existing file the resulting xml has the
following elements missing

  <?xml version="1.0" encoding="UTF-8"?>

  <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>

  I am using DocumentBuilder.parse(File file) to load the DOM tree. Is there
a way to retain or add these elements?

  Regards.

  Matt