<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/XMLParserDelegate/parser(_:foundCharacters:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSXMLParserDelegate(im)parser:foundCharacters:"
  },
  "title" : "parser(_:foundCharacters:)"
}
-->

# parser(_:foundCharacters:)

Sent by a parser object to provide its delegate with a string representing all or part of the characters of the current element.

```
optional func parser(_ parser: XMLParser, foundCharacters string: String)
```

## Parameters

`parser`

A parser object.

`string`

A string representing the complete or partial textual content of the current element.

## Discussion

The parser object may send the delegate several [`parser(_:foundCharacters:)`](/documentation/Foundation/XMLParserDelegate/parser(_:foundCharacters:)) messages to report the characters of an element. Because `string` may be only part of the total character content for the current element, you should append it to the current accumulation of characters until the element changes.

---

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)