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

# normalizeAdjacentTextNodesPreservingCDATA(_:)

Coalesces adjacent text nodes of the receiver that you have explicitly added, optionally including CDATA sections.

```
func normalizeAdjacentTextNodesPreservingCDATA(_ preserve: Bool)
```

## Parameters

`preserve`

<doc://com.apple.documentation/documentation/Swift/true> if CDATA sections are left alone as text nodes, <doc://com.apple.documentation/documentation/Swift/false> otherwise.

## Discussion

A text node with a value of an empty string is removed. When you process an input source of XML, adjacent text nodes are automatically normalized. You should invoke this method (with `preserve` as <doc://com.apple.documentation/documentation/Swift/false>) before using the [`XMLNode`](/documentation/Foundation/XMLNode) methods [`objects(forXQuery:constants:)`](/documentation/Foundation/XMLNode/objects(forXQuery:constants:)) or [`nodes(forXPath:)`](/documentation/Foundation/XMLNode/nodes(forXPath:)).

---

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)