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

Re: XML version number via DOM

From: Martijn Pieters <mj@digicool.com>
Date: Thu, 22 Mar 2001 09:19:22 +0100
To: Dylan Schiemann <dylans@yahoo.com>
Cc: Jeff Yates <pbwiz@pbwizard.com>, www-DOM@w3.org
Message-ID: <20010322091922.C24223@zopatista.com>
On Wed, Mar 21, 2001 at 07:16:07PM -0800, Dylan Schiemann wrote:
> --- Jeff Yates <pbwiz@pbwizard.com> wrote:
> > At the beginning of every XML document there is a
> > <?xml version="1.0" ?>
> > tag.  Is there a way to get this version number from
> > within DOM?  I know at
> > this time there is only one version number, but in
> > the future there may be
> > more.
> 
> I would think that it would be an attribute of that
> node. So
> document.childNodes[index].getAttribute("version")
> would do the trick, assuming a correct implementation.

A correct implementation does not model the <?xml version="1.0"?> tag; it
is not a Processing Instruction (even though some DOM implementations have
modelled the XML declaration as a PI Node). Besides, a PI doesn't have
attributes.

This isn't available in DOM level 2 at all. DOM level 3 does give access
to the information given in the XML declaration through attributes of the
Document Interface:

  Document.version
  Document.encoding
  Document.standalone

-- 
Martijn Pieters
| Software Engineer  mailto:mj@digicool.com
| Digital Creations  http://www.digicool.com/
| Creators of Zope   http://www.zope.org/
---------------------------------------------
Received on Thursday, 22 March 2001 03:19:30 GMT

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