---
title: "init(name:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/xmlelement/init(name:)"
---

# init(name:)

Returns an NSXMLElement object initialized with the specified name.

## Declaration

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

## Parameters

- `name`: A string specifying the name of the element.

## Return Value

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

## Discussion

Discussion The XML string representation of this object is <``name``></``name``>. This method invokes init(name:uri:) with the URI parameter set to nil.

## See Also

### Related Documentation

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

### Initializing NSXMLElement Objects

- [init(name:stringValue:)](foundation/xmlelement/init(name:stringvalue:).md)
- [init(name:uri:)](foundation/xmlelement/init(name:uri:)-1r286.md)
- [init(xmlString:)](foundation/xmlelement/init(xmlstring:)-7vkg7.md)
- [init(kind:options:)](foundation/xmlelement/init(kind:options:).md)
