---
title: "comment(withStringValue:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/xmlnode/comment(withstringvalue:)"
---

# comment(withStringValue:)

Returns an XMLNode object representing a comment node containing given text.

## Declaration

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

## Parameters

- `stringValue`: A string specifying the text of the comment. You may specify nil or an empty string (see Return Value).

## Return Value

Return Value An XMLNode object representing an comment node (XMLNode.Kind.comment) containing the text stringValue or nil if the object couldn’t be created. If stringValue is nil or an empty string, a content-less comment node is returned (<!--->).

## See Also

### Creating and Initializing Node Objects

- [init(kind:)](foundation/xmlnode/init(kind:).md)
- [init(kind:options:)](foundation/xmlnode/init(kind:options:).md)
- [document()](foundation/xmlnode/document().md)
- [document(withRootElement:)](foundation/xmlnode/document(withrootelement:).md)
- [element(withName:)](foundation/xmlnode/element(withname:).md)
- [element(withName:children:attributes:)](foundation/xmlnode/element(withname:children:attributes:).md)
- [element(withName:stringValue:)](foundation/xmlnode/element(withname:stringvalue:).md)
- [element(withName:uri:)](foundation/xmlnode/element(withname:uri:).md)
- [attribute(withName:stringValue:)](foundation/xmlnode/attribute(withname:stringvalue:).md)
- [attribute(withName:uri:stringValue:)](foundation/xmlnode/attribute(withname:uri:stringvalue:).md)
- [text(withStringValue:)](foundation/xmlnode/text(withstringvalue:).md)
- [namespace(withName:stringValue:)](foundation/xmlnode/namespace(withname:stringvalue:).md)
- [dtdNode(withXMLString:)](foundation/xmlnode/dtdnode(withxmlstring:).md)
- [predefinedNamespace(forPrefix:)](foundation/xmlnode/predefinednamespace(forprefix:).md)
- [processingInstruction(withName:stringValue:)](foundation/xmlnode/processinginstruction(withname:stringvalue:).md)
