<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/XMLNode/child(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSXMLNode(im)childAtIndex:"
  },
  "title" : "child(at:)"
}
-->

# child(at:)

Returns the child node of the receiver at the specified location.

```
func child(at index: Int) -> XMLNode?
```

## Parameters

`index`

An integer specifying a node position in the receiver’s array of children. If `index` is out of bounds, an exception is raised.

## Return Value

An NSXMLNode object or `nil` f the receiver has no children.

## Discussion

The receiver should be an `NSXMLNode` object representing a document, element, or document type declaration. The returned node object can represent an element, comment, text, or processing instruction.

---

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)