entities property (doctype)
Returns a collection of available entity nodes in the document.
Entity nodes identify name/value pairs.
The entity name can be used in the document as a shorter format (&name;), instead of the entity value.
Declaring entities is only allowed in XML documents.
Declaring entities is only allowed in XML documents.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read-only.
Possible values:
Collection of entities.
Default: this property has no default value.
Example HTML code 1:
This example shows how to access the entities in an XML file:
|
|||||||
<head> <script type="text/javascript" src="ajax.js"></script> <script type="text/javascript"> var httpRequest = null; function SendRequest () { if (!httpRequest) { httpRequest = CreateHTTPRequestObject (); // defined in ajax.js } if (httpRequest) { var url = "doctype_test.xml"; httpRequest.open ("GET", url, true); // async httpRequest.onreadystatechange = OnStateChange; httpRequest.send (null); } } function OnStateChange () { if (httpRequest.readyState == 0 || httpRequest.readyState == 4) { if (IsRequestSuccessful (httpRequest)) { // defined in ajax.js Test_Entities (); } else { alert ("Operation failed."); } } } function Test_Entities () { var xmlDoc = ParseHTTPResponse (httpRequest); // defined in ajax.js if (!xmlDoc) return; var message = ""; if (xmlDoc.doctype) { var entities = xmlDoc.doctype.entities; if (entities) { message += entities.length + " entities found.<br />"; for (var i = 0; i < entities.length; i++) { message += "name: <b>" + entities[i].nodeName + "</b> - "; message += "value: <b>" + entities[i].firstChild.data + "</b>.<br />"; } } else { message += "Your browser doesn't support the entities property!<br />"; } var notations = xmlDoc.doctype.notations; if (notations) { message += notations.length + " notations found.<br />"; for (var i = 0; i < notations.length; i++) { message += "name: <b>" + notations[i].nodeName + "</b> - "; message += "publicId: <b>" + notations[i].publicId + "</b>.<br />"; } } else { message += "Your browser doesn't support the notations property!<br />"; } if (xmlDoc.doctype.internalSubset) { var repaired = xmlDoc.doctype.internalSubset; repaired = repaired.replace (/\</g, "<"); repaired = repaired.replace (/\x0a/g, "<br />"); message += "The entire content of the DTD: <b>" + repaired + "</b><br />"; } else { message += "Your browser doesn't support the internalSubset property!<br />"; } } else { message += "Your browser doesn't support the doctype property!<br />"; } var info = document.getElementById ("info"); info.innerHTML = message; } </script> </head> <body onload="SendRequest ();"> <div id="info" style="width:500px; height:300px; overflow:auto; background-color:#e0d0d0;"></div> </body> |
|||||||
|
|||||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments