Re: Document.getElementById() in XML documents

David Flanagan wrote:

> The DOM Level 2 spec has this to say about Document.getElementById():
> 
> "Note: The DOM implementation must have information that says which
> attributes are of type ID. Attributes with the name "ID" are not of type
> ID unless so defined. Implementations that do not know whether
> attributes are of type ID or not are expected to return null."
> 
> I'm surprised by that last sentence, and I'd like to know whether that
> is actually how things are implemented in practice.  Although I haven't
> done it myself, I gather that the latest web browsers can display XML
> documents when they've got an appropriate stylesheet.  I doubt that
> those browsers are actually going out and parsing a DTD to determine the
> type of each attribute, but I'd also really be surprised if they don't
> just make getElementById() work with attributes named "ID".  In
> practice, this seems like too important a method to break over a
> technicality like this.
> 
> I'd be interested to hear from anyone who can comment on how this issue
> is actually being handled in practice.
> 


For document.getElementById() to work in Mozilla/Netscape6+ when 
document is an XML document you do indeed need to tell mozilla what 
attributes are ID's (and due to bugs in mozilla you need to do this in 
the internal subset).


>     David Flanagan
> 
> 


-- 
jst

Received on Thursday, 2 August 2001 05:07:56 UTC