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

# init(name:)

Returns an `NSXMLElement` object initialized with the specified name.

```
convenience init(name: String)
```

## Parameters

`name`

A string specifying the name of the element.

## Return Value

The initialized `NSXMLElement` object or `nil` if initialization did not succeed.

## Discussion

The XML string representation of this object is `<``name``></``name``>`. This method invokes [`init(name:uri:)`](/documentation/Foundation/XMLElement/init(name:uri:)-1r286) with the URI parameter set to `nil`.

## See Also

  [Tree-Based XML Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/NSXML_Concepts/NSXML.html#//apple_ref/doc/uid/TP40001269)



---

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)