DocumentType.entities
The entities property contains a NamedNodeMap of
all entities (both internal and external) declared in the Document Type Definition.
Duplicates are ignored.
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">
]>
<staff>
<employee ssn="123456" pay="3">
<name>John Sullivan</name>
<position>&snrex;</position>
</employee>
<employee ssn="987654" pay="2">
<name>Mary Lopez</name>
<position>&pa;</position>
</employee>
</staff>
Note:
The code above represents the raw XML; when viewed in a browser both of the entities
'&snrex;' and '&pa;' will be expanded to the values defined for them in the DOCTYPE
declaration (i.e. 'senior executive' and 'personal assistant' respectively).
The code then gets a DocumentType object for this document, and produces a
NamedNodeMap of all its entities. It then iterates through the
list displaying the name and text of each.
Code (VBScript):
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("staff.xml")
Set DocType = objXMLDoc.doctype
Set EntList = DocType.entities
For Each Ent In EntList
document.write(Ent.nodeName)
document.write(": " & Ent.text & "<br>")
Next
Output:
snrex: senior executive
pa: personal assistant
|