---
title: "init(xmlString:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/xmldtdnode/init(xmlstring:)-1dyhd"
---

# init(xmlString:)

Returns an NSXMLDTDNode object initialized with the DTD declaration in a given string.

## Declaration

```swift
init?(xmlString string: String)
```

## Parameters

- `string`: The DTD declaration.

## Return Value

Return Value An NSXMLDTDNode object initialized with the DTD declaration in string. Returns nil if initialization did not succeed, as might occur if the passed-in declaration is malformed.

## Discussion

Discussion The node kind (NSXMLNode) assigned to the returned object—element, attribute, entity, or notation declaration— is based on the full XML string that is parsed. To assign a subkind, set the dtdKind property. You may also use the dtdNode(withXMLString:) or init(kind:) methods to create NSXMLDTDNode instances. However, you cannot use the latter method to create NSXMLDTDNode instances for attribute-list declarations.

## See Also

### Related Documentation

- [Tree-Based XML Programming Guide](apple-archive/documentation/Cocoa/Conceptual/NSXML_Concepts/NSXML.html.md)
