entities (W3C DOM Core property)
| Version | Depr. | Static | Read-only |
|---|---|---|---|
| DOM1 | No | No | Yes |
| IE5.5+ | FF3 | SA3 | OP9+ |
|---|---|---|---|
| Buggy | None | None | Partial |
Example
var entities = document.doctype.entities;
The
example above saves a reference to the entities
collection, which itself is a property of the doctype. Each member of the collection is a
Entity node, and can be retrieved using the getNamedItem method:
entities.getNamedItem('hawk')
Description
The
entities collection is a is an unordered
list of the general entities declared in the DTD. Both external and
internal entities should be included; duplicates should be discarded.
This collection is a NamedNodeMap, primarily
intended to be accessed by name. It's also possible to access the items by
their index in the map, however the DOM does not specify what order they
will appear.
As with all named node maps,
entities is a live
collection, which means that changes to the collection it represents are
immediately reflected in the node map (as opposed to it being a static
snapshot).
Each member of this collection is an Entity node, and is readonly.
Even though a collection looks like an array, it isn't an array —
although you can iterate through it and refer to its members like an
array, you can't use Array methods like
push or pop on it.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 1.5 | 2.0 | 3.0 | 1.3 | 2.0 | 3.0 | 9.0 | 9.5 |
| Buggy | Buggy | Buggy | None | None | None | None | None | None | Partial | Partial |
This collection is very sparsely supported, but there's no other way to retrieve this data. Just gotta hope you never need to!
Only Opera in XHTML mode or
XML1 and Internet
Explorer in XML provide data for the
entities collection; in
Firefox, Safari 3
and Safari 1.3 and 2 in XHTML mode or XML the
collection is null; in other environments the doctype itself is null or
undefined (see DocumentType for details).
In
Internet Explorer in XML this collection only
includes internal entities (those defined in a doctype's internal subset),
external entities are not included. Furthermore it doesn't support
associative array syntax for retrieving members by name (eg.
entities['hawk']), it only supports reference by index
(eg. entities[0]) or using the getNamedItem method of NamedNodeMap (eg.
entities.getNamedItem('hawk')).
Footnotes
1 On XHTML pages served as
application/xhtml+xml.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.