YouTip LogoYouTip

Prop Documenttype Internalsubset

# XML DOM DocumentType: internalSubset Property The `internalSubset` property is a read-only property of the `DocumentType` interface. It returns the internal Document Type Definition (DTD) subset of an XML document as a string, excluding the delimiting square brackets `[` and `]`. If there is no internal DTD subset, it returns `null`. --- ## Syntax ```javascript documentObject.doctype.internalSubset ``` ### Return Value * **String**: The internal DTD subset declarations (e.g., elements, entities, notations) as a raw string. * **null**: Returned if there is no internal DTD subset present in the document type declaration. --- ## Code Example The following example demonstrates how to load an XML document containing an internal DTD and retrieve its internal subset using JavaScript. ### Sample XML File: `note_internal_dtd.xml` ```xml ]> Tove Jani Reminder Don't forget me this weekend! ``` ### JavaScript Implementation ```javascript // Load the XML document const xmlDoc = loadXMLDoc("note_internal_dtd.xml"); // Retrieve and display the internal DTD subset const dtdSubset = xmlDoc.doctype.internalSubset; console.log(dtdSubset); ``` ### Output The output will be the raw string representation of the declarations defined inside the square brackets of the `` declaration: ```dtd ``` --- ## Technical Considerations ### 1. Read-Only Property The `internalSubset` property is strictly **read-only**. You cannot modify the internal DTD subset dynamically by assigning a new string to this property. ### 2. Browser Compatibility and Parser Support * Modern web browsers parsing XML documents via `DOMParser` or standard AJAX requests fully support `document.doctype.internalSubset`. * If the XML document is parsed as HTML (which does not support internal DTD subsets), the `doctype` object may not expose this property, or it will return `null`. * Ensure that your XML parser is configured to preserve external/internal DTD declarations if you are working in non-browser environments (such as Node.js with specific DOM libraries).
← Prop Documenttype NameAdo Datatypes β†’