<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/XMLNode/Options",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@E@NSXMLNodeOptions"
  },
  "title" : "XMLNode.Options"
}
-->

# XMLNode.Options

These constants are input and output options for all `NSXMLNode` objects (unless otherwise indicated), including [`XMLDocument`](/documentation/Foundation/XMLDocument) objects. You can specify these options in the `NSXMLNode` methods [`init(kind:options:)`](/documentation/Foundation/XMLNode/init(kind:options:)) and [`xmlString(options:)`](/documentation/Foundation/XMLNode/xmlString(options:)).

```
struct Options
```

## Overview

The options with “Preserve” in their names are applicable only when external sources of XML are parsed; they have no effect on node objects that are programmatically created. Other options are used in initialization and output methods of `NSXMLDocument`; see the [`XMLDocument`](/documentation/Foundation/XMLDocument) reference documentation for details.

## Topics

### Type Properties

### Constants

[`documentIncludeContentTypeDeclaration`](/documentation/Foundation/XMLNode/Options/documentIncludeContentTypeDeclaration)

Includes a content type declaration for HTML or XHTML in the output of the document.

[`documentTidyHTML`](/documentation/Foundation/XMLNode/Options/documentTidyHTML)

Formats HTML into valid XHTML during processing of the document.

[`documentTidyXML`](/documentation/Foundation/XMLNode/Options/documentTidyXML)

Changes malformed XML into valid XML during processing of the document.

[`documentValidate`](/documentation/Foundation/XMLNode/Options/documentValidate)

Validates this document against its DTD (internal or external) or XML Schema.

[`documentXInclude`](/documentation/Foundation/XMLNode/Options/documentXInclude)

Replaces all XInclude nodes in the document with the nodes referred to.

[`nodeCompactEmptyElement`](/documentation/Foundation/XMLNode/Options/nodeCompactEmptyElement)

Requests that an element should be contracted when empty; for example, `<flag/>`.

[`nodeExpandEmptyElement`](/documentation/Foundation/XMLNode/Options/nodeExpandEmptyElement)

Requests that an element should be expanded when empty; for example, `<flag></flag>`. This is the default.

[`nodeIsCDATA`](/documentation/Foundation/XMLNode/Options/nodeIsCDATA)

Specifies that a text node contains and is written out as a CDATA section.

[`nodeLoadExternalEntitiesAlways`](/documentation/Foundation/XMLNode/Options/nodeLoadExternalEntitiesAlways)

Requests that external entities are always loaded.

[`nodeLoadExternalEntitiesNever`](/documentation/Foundation/XMLNode/Options/nodeLoadExternalEntitiesNever)

Requests that external entities are never loaded.

[`nodeLoadExternalEntitiesSameOriginOnly`](/documentation/Foundation/XMLNode/Options/nodeLoadExternalEntitiesSameOriginOnly)

Requests that external entities are always loaded and only applies when a URL has been provided.

[`nodeNeverEscapeContents`](/documentation/Foundation/XMLNode/Options/nodeNeverEscapeContents)

[`nodePreserveAll`](/documentation/Foundation/XMLNode/Options/nodePreserveAll)

[`nodePreserveAttributeOrder`](/documentation/Foundation/XMLNode/Options/nodePreserveAttributeOrder)

Requests that NSXMLNode preserve the order of attributes as in the source XML.

[`nodePreserveCDATA`](/documentation/Foundation/XMLNode/Options/nodePreserveCDATA)

Requests that NSXMLNode preserve CDATA blocks where defined in the input XML.

[`nodePreserveCharacterReferences`](/documentation/Foundation/XMLNode/Options/nodePreserveCharacterReferences)

Specifies that character references (`&#`*nnn*`;`) should not be resolved for XML output of this node.

[`nodePreserveDTD`](/documentation/Foundation/XMLNode/Options/nodePreserveDTD)

Specifies that declarations in a DTD should be preserved until it the DTD is modified. For example, parameter entities are by default expanded; with this option, they are written out as they originally occur in the DTD.

[`nodePreserveEmptyElements`](/documentation/Foundation/XMLNode/Options/nodePreserveEmptyElements)

Specifies that empty elements in the input XML be preserved in their contracted or expanded form.

[`nodePreserveEntities`](/documentation/Foundation/XMLNode/Options/nodePreserveEntities)

Specifies that entities (`&`*xyz*`;`) should not be resolved for XML output of this node.

[`nodePreserveNamespaceOrder`](/documentation/Foundation/XMLNode/Options/nodePreserveNamespaceOrder)

Requests NSXML to preserve the order of namespace URI definitions as in the source XML.

[`nodePreservePrefixes`](/documentation/Foundation/XMLNode/Options/nodePreservePrefixes)

Requests NSXMLNode not to choose prefixes based on the closest namespace URI definition.

[`nodePreserveQuotes`](/documentation/Foundation/XMLNode/Options/nodePreserveQuotes)

Specifies that the quoting style used in the input XML (single or double quotes) be preserved.

[`nodePreserveWhitespace`](/documentation/Foundation/XMLNode/Options/nodePreserveWhitespace)

Requests NSXMLNode to preserve whitespace characters (such as tabs and carriage returns) in the XML source that are not part of node content.

[`nodePrettyPrint`](/documentation/Foundation/XMLNode/Options/nodePrettyPrint)

Print this node with extra space for readability. (Output)

[`nodePromoteSignificantWhitespace`](/documentation/Foundation/XMLNode/Options/nodePromoteSignificantWhitespace)

[`nodeUseDoubleQuotes`](/documentation/Foundation/XMLNode/Options/nodeUseDoubleQuotes)

Requests that NSXML use double quotes for the value of an attribute or namespace node. This is the default.

[`nodeUseSingleQuotes`](/documentation/Foundation/XMLNode/Options/nodeUseSingleQuotes)

Requests that NSXML use single quotes for the value of an attribute or namespace node.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)