<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/XMLNode/dtdNode(withXMLString:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSXMLNode(cm)DTDNodeWithXMLString:"
  },
  "title" : "dtdNode(withXMLString:)"
}
-->

# dtdNode(withXMLString:)

Returns a [`XMLDTDNode`](/documentation/Foundation/XMLDTDNode) object representing the DTD declaration for an element, attribute, entity, or notation based on a given string.

```
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

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

## Discussion

For example, if `string` is the following:

```objc
<!ENTITY name (#PCDATA)>
```

`NSXMLNode` is able to assign the created node object a kind of [`XMLNode.Kind.entityDeclaration`](/documentation/Foundation/XMLNode/Kind-swift.enum/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.

---

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)