## XML DOM: xmlStandalone Property
The `xmlStandalone` property is a part of the XML DOM Document object. It is used to set or retrieve whether an XML document is "standalone"βmeaning it does not rely on external declarations or external Document Type Definitions (DTDs) to resolve its content.
---
## Definition and Usage
In an XML declaration, the `standalone` attribute specifies whether the document depends on external markup declarations:
* **`true`**: The document is standalone and does not require any external DTDs or external parameter entities to be parsed correctly.
* **`false`**: The document is not standalone and may rely on external DTDs or external definitions.
The `xmlStandalone` property allows you to programmatically check or modify this attribute within your XML DOM tree.
---
## Syntax
### Get the standalone status:
```javascript
let isStandalone = documentObject.xmlStandalone;
```
### Set the standalone status:
```javascript
documentObject.xmlStandalone = true | false;
```
### Return Value / Property Value
* **Boolean**: Returns `true` if the document is standalone, and `false` otherwise.
---
## Code Example
The following example loads an XML file (`books.xml`) using a custom parser function `loadXMLDoc()` and retrieves its XML declaration properties, including `xmlStandalone`, `xmlEncoding`, and `xmlVersion`.
### Sample XML File (`books.xml`)
```xml
Everyday Italian
Giada De Laurentiis
2005
30.00
```
### JavaScript Implementation
```javascript
// Load the XML document
const xmlDoc = loadXMLDoc("books.xml");
// Retrieve and display XML declaration properties
document.write("XML encoding: " + xmlDoc.xmlEncoding);
document.write("
");
document.write("XML standalone: " + xmlDoc.xmlStandalone);
document.write("
");
document.write("XML version: " + xmlDoc.xmlVersion);
document.write("
");
document.write("Encoding used when parsing: " + xmlDoc.inputEncoding);
```
### Expected Output
```text
XML encoding: UTF-8
XML standalone: false
XML version: 1.0
Encoding used when parsing: UTF-8
```
---
## Considerations and Browser Compatibility
1. **DOM Level 3 Standard**: The `xmlStandalone` property is part of the DOM Level 3 Core specification.
2. **Read/Write Behavior**: According to the W3C specification, this property is read-write. However, setting this property only modifies the DOM representation in memory. If you serialize the DOM back to an XML string, the serializer will output the updated `standalone` attribute in the XML declaration.
3. **Browser Support**: Modern browsers supporting standard XML DOM APIs fully support this property. If the XML document does not explicitly define a `standalone` attribute in its declaration, the property typically defaults to `false` or `undefined` depending on the browser's parser implementation.