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

# setStringValue(_:resolvingEntities:)

Sets the content of the receiver as a string value and, optionally, resolves character references, predefined entities, and user-defined entities as declared in the associated DTD.

```
func setStringValue(_ string: String, resolvingEntities resolve: Bool)
```

## Parameters

`string`

A string to assign as the value of the receiver.

`resolve`

<doc://com.apple.documentation/documentation/Swift/true> to resolve character references, predefined entities, and user-defined entities as declared in the associated DTD; <doc://com.apple.documentation/documentation/Swift/false> otherwise. Namespace and processing-instruction nodes have their entities resolved even if `resolve` is <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

User-defined entities not declared in the DTD remain in their unresolved form. This method can only be invoked on `NSXMLNode` objects that may have content, specifically elements, attributes, namespaces, processing instructions, text, and DTD-declaration nodes. Setting the string value of a node object removes all existing children, including processing instructions and comments. Setting the string value of an element -node object creates a text node as the sole child.

---

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)