---
title: "init(name:stringValue:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/xmlelement/init(name:stringvalue:)"
---

# init(name:stringValue:)

Returns an NSXMLElement object initialized with a specified name and a single text-node child containing a specified value.

## Declaration

```swift
convenience init(name: String, stringValue string: String?)
```

## Parameters

- `name`: A string specifying the name of the element.
- `string`: The string value of the receiver’s text node.

## Return Value

Return Value The initialized NSXMLElement object or nil if initialization did not succeed.

## Discussion

Discussion The string representation of this object is <``name``>``string``</``name``>.

## See Also

### Initializing NSXMLElement Objects

- [init(name:)](foundation/xmlelement/init(name:).md)
- [init(name:uri:)](foundation/xmlelement/init(name:uri:)-1r286.md)
- [init(xmlString:)](foundation/xmlelement/init(xmlstring:)-7vkg7.md)
- [init(kind:options:)](foundation/xmlelement/init(kind:options:).md)
