A representation of a Document Type Definition.


@interface NSXMLDTD : NSXMLNode


An instance of the NSXMLDTD class is held as a property of an NSXMLDocument instance, accessed through the NSXMLDocument method DTD (and set via setDTD:).

In the data model, an NSXMLDTD object is conceptually similar to namespace and attribute nodes: it is not considered to be a child of the NSXMLDocument 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 NSXMLDTDNode class as well as NSXMLNode 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 NSXMLDTD instance is in place, you can add, remove, and change the NSXMLDTDNode 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 NSXMLDocument instance). You may also programmatically create an external DTD and write that out to its own file.


Initializing an NSXMLDTD Object

- initWithContentsOfURL:options:error:

Initializes and returns an NSXMLDTD object created from the DTD declarations in a URL-referenced source.

- initWithData:options:error:

Initializes and returns an NSXMLDTD object created from the DTD declarations encapsulated in an NSData object

Managing DTD Identifiers


Returns the receiver’s public identifier.


Returns the receiver’s system identifier.

Manipulating Child Nodes

- addChild:

Adds a child node to the end of the list of existing children.

- insertChild:atIndex:

Inserts a child node in the receiver’s list of children at a specific location in the list.

- insertChildren:atIndex:

Inserts an array of child nodes at a specified location in the receiver’s list of children.

- removeChildAtIndex:

Removes the child node at a particular location in the receiver’s list of children.

- replaceChildAtIndex:withNode:

Replaces a child at a particular index with another child.

- setChildren:

Removes all existing children of the receiver and replaces them with an array of new child nodes.

Getting DTD Nodes by Name

+ predefinedEntityDeclarationForName:

Returns a DTD node representing the predefined entity declaration with the specified name.

- elementDeclarationForName:

Returns the DTD node representing an element declaration for a specified element.

- attributeDeclarationForName:elementName:

Returns the DTD node representing an attribute-list declaration for a given attribute and its element.

- entityDeclarationForName:

Returns the DTD node representing the entity declaration for a specified entity.

- notationDeclarationForName:

Returns the DTD node representing the notation declaration identified by the specified notation name.



Inherits From

See Also

Tree-Based Processing


A representation of element, attribute-list, entity, and notation declarations in a Document Type Definition.


An XML document as internalized into a logical tree structure.


The element nodes in an XML tree structure.


The nodes in the abstract, logical tree structure that represents an XML document.