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

# elements(forName:)

Returns the child element nodes (as `NSXMLElement` objects) of the receiver that have a specified name.

```
func elements(forName name: String) -> [XMLElement]
```

## Parameters

`name`

A string specifying the name of the child element nodes to find and return. If `name` is a qualified name, then this method invokes [`elements(forLocalName:uri:)`](/documentation/Foundation/XMLElement/elements(forLocalName:uri:)) with the URI parameter set to the URI associated with the prefix. Otherwise comparison is based on string equality of the qualified or non-qualified name.

## Return Value

An array of of `NSXMLElement` objects or an empty array if no matching children can be found.

---

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)