Prop Documenttype Systemid
## XML DOM: DocumentType.systemId Property
The `systemId` property of the `DocumentType` object returns the **system identifier** of an external Document Type Definition (DTD) associated with the XML or HTML document.
Typically, this is a URI (such as a local file path or a web URL) pointing to the external DTD file.
---
## Syntax
```javascript
documentObject.doctype.systemId
```
### Return Value
* **String**: A string representing the system identifier (URI) of the external DTD.
* **Null**: Returns `null` if there is no external DTD or if the system identifier is not specified.
---
## Code Example
The following example demonstrates how to retrieve the system identifier of an external DTD.
Suppose we have an XML file named `note_external_dtd.xml` with the following DOCTYPE declaration:
```xml
Tove
Jani
Reminder
Don't forget me this weekend!
```
We can load this XML document and retrieve its `systemId` using JavaScript:
```javascript
// Load the XML document
var xmlDoc = loadXMLDoc("note_external_dtd.xml");
// Access the doctype and retrieve the systemId
var systemIdentifier = xmlDoc.doctype.systemId;
// Output the result
console.log(systemIdentifier);
// Output: "note.dtd"
```
---
## Practical Considerations
### 1. Difference Between `systemId` and `publicId`
* **`systemId`**: Specifies the system-dependent location of the DTD file (usually a URL or file path). It is intended for the XML parser to locate and download the DTD.
* **`publicId`**: Specifies a globally unique, system-independent public identifier (e.g., `"-//W3C//DTD XHTML 1.0 Transitional//EN"`). If a public identifier is used, the parser may look up the DTD in a local catalog before attempting to download it via the `systemId`.
### 2. HTML5 Behavior
In modern HTML5 documents, the standard doctype declaration is:
```html
```
Since HTML5 does not reference an external DTD, calling `document.doctype.systemId` in a standard HTML5 web page will return an empty string (`""`).
### 3. Browser Compatibility and Read-Only Status
* **Read-Only**: The `systemId` property is read-only. You cannot modify the DTD's system identifier dynamically after the document has been parsed.
* **Compatibility**: This property is supported across all major modern browsers and standard XML DOM parsers.
YouTip