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

# namespaces

Sets all of the namespace nodes of the receiver at once, replacing any existing namespace nodes.

```
var namespaces: [XMLNode]? { get set }
```

## Parameters

`namespaces`

An array of [`XMLNode`](/documentation/Foundation/XMLNode) objects of kind [`XMLNode.Kind.namespace`](/documentation/Foundation/XMLNode/Kind-swift.enum/namespace).  If there are namespace nodes with the same prefix, the first attribute with that prefix is used. Send this message with `namespaces` as `nil` to remove all namespace nodes.

## Discussion

---

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)