---
title: "init(kind:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/xmlnode/init(kind:)"
---

# init(kind:)

Returns an NSXMLNode instance initialized with the constant indicating node kind.

## Declaration

```swift
convenience init(kind: XMLNode.Kind)
```

## Parameters

- `kind`: An enum constant of type doc://com.apple.foundation/documentation/Foundation/XMLNode/Kind-swift.enum that indicates the type of node. See Constants for a list of valid NSXMLNodeKind constants.

## Return Value

Return Value An NSXMLNode object initialized with kind or nil if the object couldn’t be created. If kind is not a valid NSXMLNodeKind constant, the method returns an NSXMLNode object of kind NSXMLInvalidKind.

## Discussion

Discussion This method invokes init(kind:options:) with the options parameter set to NSXMLNodeOptionsNone. Do not use this initializer for creating instances of XMLDTDNode for attribute-list declarations. Instead, use the dtdNode(withXMLString:) class method of this class or the init(xmlString:) method of the NSXMLDTDNode class.

## See Also

### Related Documentation

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

### Creating and Initializing Node Objects

- [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)
- [dtdNode(withXMLString:)](foundation/xmlnode/dtdnode(withxmlstring:).md)
- [predefinedNamespace(forPrefix:)](foundation/xmlnode/predefinednamespace(forprefix:).md)
- [processingInstruction(withName:stringValue:)](foundation/xmlnode/processinginstruction(withname:stringvalue:).md)
