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

# CFXMLTreeCreateFromData

Parses the given XML data and returns the resulting CFXMLTree object.

## Declaration

```occ
extern CFXMLTreeRefCFXMLTreeCreateFromData(CFAllocatorRef allocator, CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes);
```

## Parameters

- `allocator`: The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
- `xmlData`: The XML data you wish to parse.
- `dataSource`: The URL from which the XML data was obtained. The URL is used to resolve any relative references found in xmlData. Pass NULL if a valid URL is unavailable.
- `parseOptions`: Flags which control how the XML data will be parsed. See doc://com.apple.corefoundation/documentation/CoreFoundation/CFXMLParserOptions for the list of available options.
- `versionOfNodes`: Determines which version of CFXMLNode objects are produced by the parser.

## Return Value

Return Value A new CFXMLTree object containing the data from the specified XML document. Ownership follows the The Create Rule.

## Discussion

Discussion This function represents the high-level interface to the XML parser. This single function creates a parser for the specified XML data using the specified options. The parser creates and returns a CFXMLTree object that you can examine and modify with the CFTree functions or obtain the node using the CFXMLTreeGetNode function and examine its attributes using CFXMLNode functions.

## See Also

### CFXMLTree Miscellaneous Functions

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