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

# resolvePrefix(forNamespaceURI:)

Returns the prefix associated with the specified URI.

```
func resolvePrefix(forNamespaceURI namespaceURI: String) -> String?
```

## Parameters

`namespaceURI`

A string identifying the URI associated with the namespace.

## Return Value

A string that is the matching prefix or `nil` if it finds no matching prefix.

## Discussion

The method looks in the entire namespace chain for the URI.

---

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)