---
title: CFXMLTreeCreateXMLData
framework: Core Foundation
role: symbol
role_heading: Function
platforms: [macOS 10.0+]
path: corefoundation/cfxmltreecreatexmldata
---

# CFXMLTreeCreateXMLData

Generates an XML document from a CFXMLTree object which is ready to be written to permanent storage.

## Declaration

```occ
extern CFDataRefCFXMLTreeCreateXMLData(CFAllocatorRef allocator, CFXMLTreeRef xmlTree);
```

## Parameters

- `allocator`: The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
- `xmlTree`: The CFXMLTree object you wish to convert to an XML document.

## Return Value

Return Value The XML data. Ownership follows the The Create Rule.

## Discussion

Discussion This function will not regenerate entity references replaced at the parse time (except those required for syntactic correctness). If you need this you must manually walk the tree and re-insert any entity references that should appear in the final output file.

## See Also

### CFXMLTree Miscellaneous Functions

- [CFXMLCreateStringByEscapingEntities(_:_:_:)](corefoundation/cfxmlcreatestringbyescapingentities(_:_:_:).md)
- [CFXMLCreateStringByUnescapingEntities(_:_:_:)](corefoundation/cfxmlcreatestringbyunescapingentities(_:_:_:).md)
- [CFXMLTreeCreateFromData](corefoundation/cfxmltreecreatefromdata.md)
- [CFXMLTreeCreateFromDataWithError](corefoundation/cfxmltreecreatefromdatawitherror.md)
- [CFXMLTreeCreateWithDataFromURL](corefoundation/cfxmltreecreatewithdatafromurl.md)
- [CFXMLTreeCreateWithNode](corefoundation/cfxmltreecreatewithnode.md)
- [CFXMLTreeGetNode](corefoundation/cfxmltreegetnode.md)
