---
title: XMLDTD
framework: foundation
role: symbol
role_heading: Class
path: foundation/xmldtd
---

# XMLDTD

A representation of a Document Type Definition.

## Declaration

```swift
class XMLDTD
```

## Overview

Overview An instance of the XMLDTD class is held as a property of an XMLDocument instance, accessed through the XMLDocument property dtd. In the data model, an XMLDTD object is conceptually similar to namespace and attribute nodes: it is not considered to be a child of the XMLDocument object although it is closely associated with it. It is at the “root” of a shallow tree consisting primarily of nodes representing DTD declarations. Acceptable child nodes are instances of the XMLDTDNode class as well as XMLNode objects representing comment nodes and processing-instruction nodes. You create an NSXMLDTD object in one of three ways: By processing an XML document with its own internal (in-line) DTD By process a standalone (external) DTD Programmatically Once an XMLDTD instance is in place, you can add, remove, and change the XMLDTDNode objects representing various DTD declarations. When you write the document out as XML, the new or modified internal DTD is included (assuming you set the DTD in the XMLDocument instance). You may also programmatically create an external DTD and write that out to its own file.

## Topics

### Initializing an NSXMLDTD Object

- [init(contentsOf:options:)](foundation/xmldtd/init(contentsof:options:).md)
- [init(data:options:)](foundation/xmldtd/init(data:options:).md)

### Managing DTD Identifiers

- [publicID](foundation/xmldtd/publicid.md)
- [systemID](foundation/xmldtd/systemid.md)

### Manipulating Child Nodes

- [addChild(_:)](foundation/xmldtd/addchild(_:).md)
- [insertChild(_:at:)](foundation/xmldtd/insertchild(_:at:).md)
- [insertChildren(_:at:)](foundation/xmldtd/insertchildren(_:at:).md)
- [removeChild(at:)](foundation/xmldtd/removechild(at:).md)
- [replaceChild(at:with:)](foundation/xmldtd/replacechild(at:with:).md)
- [setChildren(_:)](foundation/xmldtd/setchildren(_:).md)

### Getting DTD Nodes by Name

- [predefinedEntityDeclaration(forName:)](foundation/xmldtd/predefinedentitydeclaration(forname:).md)
- [elementDeclaration(forName:)](foundation/xmldtd/elementdeclaration(forname:).md)
- [attributeDeclaration(forName:elementName:)](foundation/xmldtd/attributedeclaration(forname:elementname:).md)
- [entityDeclaration(forName:)](foundation/xmldtd/entitydeclaration(forname:).md)
- [notationDeclaration(forName:)](foundation/xmldtd/notationdeclaration(forname:).md)

### Initializers

- [init()](foundation/xmldtd/init().md)
- [init(contentsOfURL:options:)](foundation/xmldtd/init(contentsofurl:options:).md)

## Relationships

### Inherits From

- [XMLNode](foundation/xmlnode.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Tree-Based Processing

- [XMLDTDNode](foundation/xmldtdnode.md)
- [XMLDocument](foundation/xmldocument.md)
- [XMLElement](foundation/xmlelement.md)
- [XMLNode](foundation/xmlnode.md)
