<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFXMLParser",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@T@CFXMLParserRef"
  },
  "title" : "CFXMLParser"
}
-->

# CFXMLParser

```
class CFXMLParser
```

## Overview

CFXMLParser provides an XML parser you can use to find and extract data in XML documents. You can use a high-level interface to load an XML document into a Core Foundation collection object. A low-level callback-based interface allows you to perform any action you wish on an XML structured type when it is detected by the parser. This opaque type is relevant for applications that need information about an XML document’s structure or content.

## Topics

### CFXMLParser Miscellaneous Functions

[`CFXMLParserAbort`](/documentation/CoreFoundation/CFXMLParserAbort)

Causes a parser to abort with the given error code and description.

[`CFXMLParserCopyErrorDescription`](/documentation/CoreFoundation/CFXMLParserCopyErrorDescription)

Returns the user-readable description of the current error condition.

[`CFXMLParserCreate`](/documentation/CoreFoundation/CFXMLParserCreate)

Creates a new XML parser for the specified XML data.

[`CFXMLParserCreateWithDataFromURL`](/documentation/CoreFoundation/CFXMLParserCreateWithDataFromURL)

Creates a new XML parser for the specified XML data at the specified URL.

[`CFXMLParserGetCallBacks`](/documentation/CoreFoundation/CFXMLParserGetCallBacks)

Returns the callbacks associated with an XML parser when it was created.

[`CFXMLParserGetContext`](/documentation/CoreFoundation/CFXMLParserGetContext)

Returns the context for an XML parser.

[`CFXMLParserGetDocument`](/documentation/CoreFoundation/CFXMLParserGetDocument)

Returns the top-most object returned by the create XML structure callback.

[`CFXMLParserGetLineNumber`](/documentation/CoreFoundation/CFXMLParserGetLineNumber)

Returns the line number of the current parse location.

[`CFXMLParserGetLocation`](/documentation/CoreFoundation/CFXMLParserGetLocation)

Returns the character index of the current parse location.

[`CFXMLParserGetSourceURL`](/documentation/CoreFoundation/CFXMLParserGetSourceURL)

Returns the URL for the XML data being parsed.

[`CFXMLParserGetStatusCode`](/documentation/CoreFoundation/CFXMLParserGetStatusCode)

Returns a numeric code indicating the current status of the parser.

[`CFXMLParserGetTypeID`](/documentation/CoreFoundation/CFXMLParserGetTypeID)

Returns the type identifier for the CFXMLParser opaque type.

[`CFXMLParserParse`](/documentation/CoreFoundation/CFXMLParserParse)

Begins a parse of the XML data that was associated with the parser when it was created.

### Callbacks

[`CFXMLParserAddChildCallBack`](/documentation/CoreFoundation/CFXMLParserAddChildCallBack)

Callback function invoked by the parser to notify your application of parent/child relationships between XML structures.

[`CFXMLParserCopyDescriptionCallBack`](/documentation/CoreFoundation/CFXMLParserCopyDescriptionCallBack)

Callback function invoked by the parser when handling the information pointer.

[`CFXMLParserCreateXMLStructureCallBack`](/documentation/CoreFoundation/CFXMLParserCreateXMLStructureCallBack)

Callback function invoked when the parser encounters an XML open tag.

[`CFXMLParserEndXMLStructureCallBack`](/documentation/CoreFoundation/CFXMLParserEndXMLStructureCallBack)

Callback function invoked by the parser to notify your application that an XML structure (and all its children) have been completely parsed.

[`CFXMLParserHandleErrorCallBack`](/documentation/CoreFoundation/CFXMLParserHandleErrorCallBack)

Callback function invoked by the parser to notify your application that an error has occurred.

[`CFXMLParserReleaseCallBack`](/documentation/CoreFoundation/CFXMLParserReleaseCallBack)

Callback function invoked by the parser when it wants to release a reference to the information pointer.

[`CFXMLParserResolveExternalEntityCallBack`](/documentation/CoreFoundation/CFXMLParserResolveExternalEntityCallBack)

Callback function invoked by the parser to notify your application that an external entity has been referenced.

[`CFXMLParserRetainCallBack`](/documentation/CoreFoundation/CFXMLParserRetainCallBack)

Callback function invoked by the parser when it needs another reference to the information pointer.

### Data Types

[`CFXMLParserCallBacks`](/documentation/CoreFoundation/CFXMLParserCallBacks)

Contains version information and function pointers to callbacks needed when parsing XML.

[`CFXMLParserContext`](/documentation/CoreFoundation/CFXMLParserContext)

Contains version information and function pointers to callbacks used when handling a program-defined context.

### Constants

[`CFXMLParserStatusCode`](/documentation/CoreFoundation/CFXMLParserStatusCode)

The various status and error flags that can be returned by the parser.

[`CFXMLParserOptions`](/documentation/CoreFoundation/CFXMLParserOptions)

Options you can use to control the parser’s treatment of an XML document.

## See Also

  [XML Programming Topics for Core Foundation](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFXML/CFXML.html#//apple_ref/doc/uid/10000138i)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)