---
title: "createDocumentFragment(withText:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/domhtmldocument/createdocumentfragment(withtext:)"
---

# createDocumentFragment(withText:)

Creates a document fragment containing the given text.

## Declaration

```swift
func createDocumentFragment(withText text: String!) -> DOMDocumentFragment!
```

## Parameters

- `text`: The text to convert.

## Return Value

Return Value A DOMDocumentFragment object derived from the source text.

## Discussion

Discussion This is a convenience method for the createDocumentFragment method in DOMDocument. This method creates a fragment that contains the supplied plain text.

## See Also

### Creating Document Fragments

- [createDocumentFragment(withMarkupString:baseURL:)](webkit/domhtmldocument/createdocumentfragment(withmarkupstring:baseurl:).md)
