---
title: xmlData
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/xmldocument/xmldata
---

# xmlData

Returns the XML string representation of the receiver—that is, the entire document—encapsulated in a data object.

## Declaration

```swift
var xmlData: Data { get }
```

## Discussion

Discussion This method invokes xmlData(options:) with an option of NSXMLNodeOptionsNone. The encoding used is based on the value returned from characterEncoding or UTF-8 if no valid encoding is returned by that method.

## See Also

### Writing a Document as XML Data

- [xmlData(options:)](foundation/xmldocument/xmldata(options:).md)
