The Entity object represents the actual entity (parsed or unparsed), and not
the entity declaration. If an XML processor expands entities before passing the structure
model to the DOM, the document tree will contain no
EntityReference nodes.
XML does not require a non-validating processor to expand external entities. If this is
the case, the replacement value of the entity may not be available. Where the replacement
value is available, the corresponding Entity node's child list represents the
structure of the replacement text. Otherwise the child list is empty.
An Entity does not have a parent node, and all its descendants are
read-only.
The name of an Entity is contained in the nodeName
property.
In the example that follows the 'staff.xml' file is used which contains a couple of
entities defined in the DOCTYPE declaration:
XML:
<!DOCTYPE staff SYSTEM "staff.dtd" [
<!ENTITY snrex "senior executive">
<!ENTITY pa "personal assistant">
]>
The code gets a DocumentType object for this document,
and produces a NamedNodeMap of all its entities. It then
displays the name and text of the first of these.
Code (VBScript):
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("staff.xml")
Set DocType = objXMLDoc.docType
Set EntList = DocType.entities
Set Ent = EntList(0)
document.write(Ent.nodeName & ": " & Ent.text)
Output:
snrex: senior executive
An Entity is also a Node object, and so inherits
various properties and methods from it. For details of the values returned by the
nodeName,
nodeType and nodeValue
properties for an Entity, see the Node object.
denotes a Microsoft extension to the W3C DOM.
PROPERTIES
attributes Property
This is a read-only property that returns an
NamedNodeMap for nodes that can have
attributes.
Syntax: Node.attributes
baseName Property
This is a read-only property that returns the base name for a node.
Syntax: Node.baseName
childNodes Property
This is a read-only property containing a node list of all children for those elements that
can have them.
Syntax: Node.childNodes
dataType Property
This is a read-only property that specifies the data type for the node.
Syntax: Node.dataType
definition Property
This property returns the definition of the node in the DTD or schema.
Syntax: Node.definition
firstChild Property
This is a read-only property that returns the first child node of a node. If there is none,
it returns null.
Syntax: Node.firstChild
lastChild Property
This is a read-only property that returns the last child node of a node. If there is none,
it returns null.
Syntax: Node.lastChild
namespaceURI Property
This property is read-only and returns the URI (Universal Resource Indentifier) of the
namespace.
Syntax: Node.namespaceURI