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

# init(name:uri:)

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

```
init(name: String, uri URI: String?)
```

## Parameters

`name`

A string that specifies the qualified name of the element.

`URI`

A string that specifies the namespace URI associated with the element.

## Return Value

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

## Discussion

You can look up the namespace prefix for this element node based on its URI using [`resolvePrefix(forNamespaceURI:)`](/documentation/Foundation/XMLElement/resolvePrefix(forNamespaceURI:)).  This method is the primary initializer for the `NSXMLElement` 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)