<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/XMLNode/init(kind:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSXMLNode(im)initWithKind:options:"
  },
  "title" : "init(kind:options:)"
}
-->

# init(kind:options:)

Returns an `NSXMLNode` instance initialized with the constant indicating node kind and one or more initialization options.

```
init(kind: XMLNode.Kind, options: XMLNode.Options = [])
```

## Parameters

`kind`

An `enum` constant of type [`XMLNode.Kind`](/documentation/Foundation/XMLNode/Kind-swift.enum) that indicates the type of node. See Constants for a list of valid NSXMLNodeKind constants.

`options`

One or more constants that specify initialization options; if there are multiple constants, bit-OR them together. These options request operations on the represented XML related to fidelity (for example, preserving entities), quoting style, handling of empty elements, and other things. See Constants for a list of valid node-initialization constants.

## Return Value

An `NSXMLNode` object initialized with the given kind and options, 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

Do not use this initializer for creating instances of [`XMLDTDNode`](/documentation/Foundation/XMLDTDNode) for attribute-list declarations. Instead, use the [`dtdNode(withXMLString:)`](/documentation/Foundation/XMLNode/dtdNode(withXMLString:)) class method of this class or the [`init(xmlString:)`](/documentation/Foundation/XMLDTDNode/init(xmlString:)-1dyhd) method of the `NSXMLDTDNode` class.

---

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)