---
title: "dtdNode(withXMLString:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/xmlnode/dtdnode(withxmlstring:)"
---

# dtdNode(withXMLString:)

Returns a XMLDTDNode object representing the DTD declaration for an element, attribute, entity, or notation based on a given string.

## Declaration

```swift
class func dtdNode(withXMLString string: String) -> Any?
```

## Parameters

- `string`: A string that is a DTD declaration. The receiver parses this string to determine the kind of DTD node to create.

## Return Value

Return Value An NSXMLDTDNode object representing the DTD declaration or nil if the object couldn’t be created.

## Discussion

Discussion For example, if string is the following: <!ENTITY name (#PCDATA)> NSXMLNode is able to assign the created node object a kind of XMLNode.Kind.entityDeclaration by parsing “ENTITY”. Note that if an attribute-list declaration (<!ATTLIST...> )has multiple attributes NSXMLNode only creates an NSXMLDTDNode object for the last attribute in the declaration.

## See Also

### Creating and Initializing Node Objects

- [init(kind:)](foundation/xmlnode/init(kind:).md)
- [init(kind:options:)](foundation/xmlnode/init(kind:options:).md)
- [document()](foundation/xmlnode/document().md)
- [document(withRootElement:)](foundation/xmlnode/document(withrootelement:).md)
- [element(withName:)](foundation/xmlnode/element(withname:).md)
- [element(withName:children:attributes:)](foundation/xmlnode/element(withname:children:attributes:).md)
- [element(withName:stringValue:)](foundation/xmlnode/element(withname:stringvalue:).md)
- [element(withName:uri:)](foundation/xmlnode/element(withname:uri:).md)
- [attribute(withName:stringValue:)](foundation/xmlnode/attribute(withname:stringvalue:).md)
- [attribute(withName:uri:stringValue:)](foundation/xmlnode/attribute(withname:uri:stringvalue:).md)
- [text(withStringValue:)](foundation/xmlnode/text(withstringvalue:).md)
- [comment(withStringValue:)](foundation/xmlnode/comment(withstringvalue:).md)
- [namespace(withName:stringValue:)](foundation/xmlnode/namespace(withname:stringvalue:).md)
- [predefinedNamespace(forPrefix:)](foundation/xmlnode/predefinednamespace(forprefix:).md)
- [processingInstruction(withName:stringValue:)](foundation/xmlnode/processinginstruction(withname:stringvalue:).md)
