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

# parser(_:foundCDATA:)

Sent by a parser object to its delegate when it encounters a CDATA block.

```
optional func parser(_ parser: XMLParser, foundCDATA CDATABlock: Data)
```

## Parameters

`parser`

An `NSXMLParser` object parsing XML.

`CDATABlock`

A data object containing a block of CDATA.

## Discussion

Through this method the parser object passes the contents of the block to its delegate in an [`NSData`](/documentation/Foundation/NSData) object. The CDATA block is character data that is ignored by the parser. The encoding of the character data is UTF-8. To convert the data object to a string object, use the `NSString` method [`init(data:encoding:)`](/documentation/Foundation/NSString/init(data:encoding:)).

---

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)