| Derived from | |
| Framework | CoreFoundation/CoreFoundation.h |
| Companion guide | |
| Declared in | CFXMLNode.h CFXMLParser.h |
A CFXMLTree object is simply a CFTree object whose context data is known to be a CFXMLNode object. CFXMLTree is derived from CFTree—you can pass CFXMLTree objects in all the CFTree functions. As such, a CFXMLTree object can be used to represent an entire XML document; the CFTree object provides the tree structure of the document, while the CFXMLNode objects identify and describe the nodes of the tree. An XML document can be parsed to a CFXMLTree object, and a CFXMLTree object can generate the data for the equivalent XML document. This opaque type is expected to be used in conjunction with CFXMLParser and CFXMLNode objects.
Given a CFString object containing XML source, returns a CFString object with the specified XML entities escaped. The standard XML entities are always replaced.
CFStringRef CFXMLCreateStringByEscapingEntities( CFAllocatorRef allocator, CFStringRef string, CFDictionaryRef entitiesDictionary, );
The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
Any CFString object that may contain XML source. This function translates anything in the entities dictionary into the entities as specified. However, this function does not distinguish between tags and the text between tags.
Specifies the entities to be replaced. Dictionary keys should be the entities themselves, and the values should be CFString objects containing the expansion. Pass NULL to indicate no entities other than the standard five.
A CFString object derived from string with entities in entitiesDictionary replaced. Ownership follows the Create Rule.
CFXMLParser.hGiven a CFString object containing XML source, returns a CFString object with the specified XML entities not escaped. The standard XML entities are always replaced.
CFStringRef CFXMLCreateStringByUnescapingEntities( CFAllocatorRef allocator, CFStringRef string, CFDictionaryRef entitiesDictionary, );
The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
Any CFString object that may contain XML source. This function translates anything in the entities dictionary into the entities as specified. However, this function does not distinguish between tags and the text between tags.
Specifies the entities that should be replaced. Dictionary keys should be the entities themselves, and the values should be CFString objects containing the expansion. Pass NULL to indicate no entities other than the standard five.
A CFString object derived from string with entities in entitiesDictionary that are not replaced. Ownership follows the Create Rule.
CFXMLParser.h
Parses the given XML data and returns the resulting CFXMLTree object.
CFXMLTreeRef CFXMLTreeCreateFromData ( CFAllocatorRef allocator, CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes );
The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
The XML data you wish to parse.
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.
Flags which control how the XML data will be parsed. See “Parsing Options” for the list of available options.
Determines which version of CFXMLNode objects are produced by the parser.
A new CFXMLTree object containing the data from the specified XML document. Ownership follows the Create Rule.
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.
CFXMLParser.h
Parses the given XML data and returns the resulting CFXMLTree object and any error information.
CFXMLTreeRef CFXMLTreeCreateFromDataWithError ( CFAllocatorRef allocator, CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes CFDictionaryRef *errorDict );
The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
The XML data you wish to parse.
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.
Flags which control how the XML data will be parsed. See “Parsing Options” for the list of available options.
Determines which version of CFXMLNode objects are produced by the parser.
Upon return, if an error occurs contains a CFDictionary object that describes the error. If no errors occur, this parameter is not changed. Pass NULL if you don’t want error information. See “Error Dictionary Keys” for a description of the key-value pairs in this dictionary. Ownership follows the Create Rule.
A new CFXMLTree object containing the data from the specified XML document. Ownership follows the Create Rule.
Use this function instead of CFXMLTreeCreateFromData if you need access to XML parsing errors.
CFXMLParser.h
Creates a new CFXMLTree object by loading the data to be parsed directly from a data source.
CFXMLTreeRef CFXMLTreeCreateWithDataFromURL ( CFAllocatorRef allocator, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes );
The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
The URL from which the XML data is obtained. The URL is used to resolve any relative references found in XML Data. Pass NULL if a valid URL is unavailable.
Flags which control how the XML data will be parsed. See “Parsing Options” for the list of available options.
Determines which version of CFXMLNode objects are produced by the parser.
A new CFXMLTree object containing the data from the specified XML data source. Ownership follows the Create Rule.
CFXMLParser.h
Creates a childless, parentless CFXMLTree object node for a CFXMLNode object.
CFXMLTreeRef CFXMLTreeCreateWithNode ( CFAllocatorRef allocator, CFXMLNodeRef node );
The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
The CFXMLNode object to use when creating the new CFXMLTree object.
A CFXMLTree object. Ownership follows the Create Rule.
CFXMLNode.h
Generates an XML document from a CFXMLTree object which is ready to be written to permanent storage.
CFDataRef CFXMLTreeCreateXMLData ( CFAllocatorRef allocator, CFXMLTreeRef xmlTree );
The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
The CFXMLTree object you wish to convert to an XML document.
The XML data. Ownership follows the Create Rule.
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.
CFXMLParser.h
Returns the node of a CFXMLTree object.
CFXMLNodeRef CFXMLTreeGetNode ( CFXMLTreeRef xmlTree );
The CFXMLTree object whose node you wish to obtain.
The node of xmlTree. Ownership follows the Get Rule.
CFXMLNode.hA reference to a CFXMLTree object.
typedef CFTreeRef CFXMLTreeRef;
When using the high-level parser API, XML data is parsed to a special CFTree object which is simply a CFXMLTree object with known contexts and callbacks. The nodes of a CFXMLTree may be queried using the basic CFTree functions (to report on the structure of the tree itself), or via the functions here (to report on the XML contents of the nodes).
CFXMLNode.hThe keys used in an error dictionary returned by some functions to provide more information about XML parse errors.
const CFStringRef kCFXMLTreeErrorDescription; const CFStringRef kCFXMLTreeErrorLineNumber; const CFStringRef kCFXMLTreeErrorLocation; const CFStringRef kCFXMLTreeErrorStatusCode;
kCFXMLTreeErrorDescriptionDictionary key whose value is a CFString containing a readable description of the error.
Available in Mac OS X v10.3 and later.
Declared in CFXMLParser.h
kCFXMLTreeErrorLineNumberDictionary key whose value is a CFNumber containing the line number where the error was detected. This may not be the line number where the actual XML error is located.
Available in Mac OS X v10.3 and later.
Declared in CFXMLParser.h
kCFXMLTreeErrorLocationDictionary key whose value is a CFNumber containing the byte location where the error was detected.
Available in Mac OS X v10.3 and later.
Declared in CFXMLParser.h
kCFXMLTreeErrorStatusCodeDictionary key whose value is a CFNumber containing the error status code. See CFXMLParser for possible status code values.
Available in Mac OS X v10.3 and later.
Declared in CFXMLParser.h
These keys are used in the error dictionary returned by the CFXMLTreeCreateFromDataWithError function.
Last updated: 2006-02-07