<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/XMLNode/text(withStringValue:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSXMLNode(cm)textWithStringValue:"
  },
  "title" : "text(withStringValue:)"
}
-->

# text(withStringValue:)

Returns an `NSXMLNode` object representing a text node with specified content.

```
class func text(withStringValue stringValue: String) -> Any
```

## Parameters

`stringValue`

A string that is the textual content of the node.

## Return Value

An `NSXMLNode` object of kind [`XMLNode.Kind.text`](/documentation/Foundation/XMLNode/Kind-swift.enum/text) initialized with the textual `value` or `nil` if the object couldn’t be created.

---

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)