| Derived from | |
| Framework | CoreFoundation/CoreFoundation.h |
| Companion guide | |
| Declared in | CFXMLNode.h |
A CFXMLNode object describes an individual XML construct—like a tag, or a comment, or a string of character data. CFXMLNode is intended to be used with the CFXMLParser and CFXMLTree opaque types.
Each CFXMLNode object contains three main pieces of information—the node's type, the data string, and a pointer to an additional information data structure. A CFXMLNode object’s type is one of the enumerations described in Node Type Code. The data string is always a CFString object; the meaning of the string is dependent on the node's type. The format of the additional data is also dependent on the node's type; in general, there is a custom structure for each type that requires additional data. See Node Type Code for the mapping from a node type to meaning of the data string, and structure of the additional information. Note that these structures are versioned and may change as the parser changes. The current version can always be identified by the kCFXMLNodeCurrentVersion constant; earlier versions can be identified and used by passing earlier values for the version number (although the older structures would have been removed from the header).
You create a CFXMLNode object using one of the create or copy functions. Use the CFXMLNodeGetTypeCode, CFXMLNodeGetString, and CFXMLNodeGetInfoPtr functions to get the node type, data string, and additional information respectively. Use the CFXMLNodeGetVersion function to get a node’s version number.
Creates a new CFXMLNode.
CFXMLNodeRef CFXMLNodeCreate ( CFAllocatorRef alloc, CFXMLNodeTypeCode xmlType, CFStringRef dataString, const void *additionalInfoPtr, CFIndex version );
The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
Type identifier code for the XML structure you want this node to describe.
The XML data.
A pointer to a structure containing additional information about the XML data.
The version number of the CFXMLNode object you want to create. Pass one of the pre-defined constants, typically kCFXMLNodeCurrentVersion.
A new CFXMLNode object. Ownership follows the Create Rule.
CFXMLNode.hCreates a copy of a CFXMLNode object.
CFXMLNodeRef CFXMLNodeCreateCopy ( CFAllocatorRef alloc, CFXMLNodeRef origNode );
The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
The node to copy. Do not pass NULL.
A new CFXMLNode object. Ownership follows the Create Rule.
CFXMLNode.hReturns the additional information pointer of a CFXMLNode object.
const void * CFXMLNodeGetInfoPtr ( CFXMLNodeRef node );
The CFXMLNode object to examine.
A pointer to a structure containing additional information. The CFXMLNode version together with the node’s type determines the expected structure. See Node Type Code for information about the possible structures returned. If the returned value is a Core Foundation object, ownership follows the Get Rule.
CFXMLNode.hReturns the data string from a CFXMLNode.
CFStringRef CFXMLNodeGetString ( CFXMLNodeRef node );
The CFXMLNode object to examine.
The data string from node. Ownership follows the Get Rule.
CFXMLNode.hReturns the XML structure type code for a CFXMLNode object.
CFXMLNodeTypeCode CFXMLNodeGetTypeCode ( CFXMLNodeRef node );
The CFXMLNode object to examine.
The type code for node.
CFXMLNode.hReturns the type identifier code for the CFXMLNode opaque type.
CFTypeID CFXMLNodeGetTypeID ( void );
The type identifier for the CFXMLNode opaque type.
CFXMLNode.hReturns the version number for a CFXMLNode object.
CFIndex CFXMLNodeGetVersion ( CFXMLNodeRef node );
The CFXMLNode object to examine.
The version number of node.
CFXMLNode.hContains information about an element attribute definition.
struct CFXMLAttributeDeclarationInfo {
CFStringRef attributeName;
CFStringRef typeString;
CFStringRef defaultString;
};
typedef struct CFXMLAttributeDeclarationInfo CFXMLAttributeDeclarationInfo;
attributeNameThe name of the attribute.
typeStringDescribes the declaration of a single attribute.
defaultStringThe attribute's default value.
This structure is part of the definition of the CFXMLAttributeListDeclarationInfo structure.
CFXMLNode.hContains a list of the attributes associated with an element.
struct CFXMLAttributeListDeclarationInfo {
CFIndex numberOfAttributes;
CFXMLAttributeDeclarationInfo *attributes;
};
typedef struct CFXMLAttributeListDeclarationInfo CFXMLAttributeListDeclarationInfo;
numberOfAttributesThe number of attributes in the array.
attributesA C array of attributes.
A pointer to this structure is included in the CFXMLNode object passed to your application when the parser encounters an attribute declaration in the DTD. Use the CFXMLNodeGetInfoPtr function to obtain the pointer to this structure.
CFXMLNode.hContains the source URL and text encoding information for the XML document.
struct CFXMLDocumentInfo {
CFURLRef sourceURL;
CFStringEncoding encoding;
};
typedef struct CFXMLDocumentInfo CFXMLDocumentInfo;
sourceURLThe source URL of the XML document.
encodingThe text encoding of the XML document.
A pointer to this structure is included in the CFXMLNode object passed to your application when the parser encounters the XML declaration. Use the CFXMLNodeGetInfoPtr function to obtain the pointer.
CFXMLNode.hContains the external ID of the DTD.
struct CFXMLDocumentTypeInfo {
CFXMLExternalID externalID;
};
typedef struct CFXMLDocumentTypeInfo CFXMLDocumentTypeInfo;
externalIDThe external ID of the DTD.
A pointer to this structure is included in the CFXMLNode object passed to your application when the parser encounters the beginning of the DTD. Use the CFXMLNodeGetInfoPtr function to obtain a pointer to this structure.
CFXMLNode.hContains a list of element attributes packaged as CFDictionary key/value pairs.
struct CFXMLElementInfo {
CFDictionaryRef attributes;
CFArrayRef attributeOrder;
Boolean isEmpty;
};
typedef struct CFXMLElementInfo CFXMLElementInfo;
attributesThe dictionary of attribute values.
attributeOrderAn array specifying the order in which the attributes appeared in the XML document.
isEmptyA flag indicating whether the element was expressed in closed form.
A pointer to this structure is included in the CFXMLNode object passed to your application when the parser encounters an element containing attributes. Use the CFXMLNodeGetInfoPtr function to obtain the pointer.
CFXMLNode.hContains a description of the element type.
struct CFXMLElementTypeDeclarationInfo {
CFStringRef contentDescription;
};
typedef struct CFXMLElementTypeDeclarationInfo CFXMLElementTypeDeclarationInfo;
contentDescriptionA textual description of the element type.
A pointer to this structure is included in the CFXMLNode passed to your application when the parser encounters and element type declaration. Use the CFXMLNodeGetInfoPtr function to obtain a pointer to this structure.
CFXMLNode.hContains information describing an XML entity.
struct CFXMLEntityInfo {
CFXMLEntityTypeCode entityType;
CFStringRef replacementText;
CFXMLExternalID entityID;
CFStringRef notationName;
};
typedef struct CFXMLEntityInfo CFXMLEntityInfo;
entityTypeThe entity type code.
replacementTextNULL if entityType is external or unparsed, otherwise the text that the entity should be replaced with.
entityIDentityID.systemID will be NULL if entityType is internal.
notationNameNULL if entityType is parsed.
A pointer to this structure is included in the CFXMLNode object passed to your application when the parser encounters an entity declaration. Use the CFXMLNodeGetInfoPtr function to obtain a pointer to this structure.
CFXMLNode.hContains information describing an XML entity reference.
struct CFXMLEntityReferenceInfo {
CFXMLEntityTypeCode entityType;
};
typedef struct CFXMLEntityReferenceInfo CFXMLEntityReferenceInfo;
entityTypeThe entity type code.
A pointer to this structure is included in the CFXMLNode object passed to your application when the parser encounters an entity reference. Use the CFXMLNodeGetInfoPtr function to obtain the pointer.
CFXMLNode.hContains the system and public IDs for an external entity reference.
struct CFXMLExternalID {
CFURLRef systemID;
CFStringRef publicID;
};
typedef struct CFXMLExternalID CFXMLExternalID;
systemIDThe systemID URL.
publicIDThe publicID string.
This structure is part of the definition of the CFXMLDocumentTypeInfo, CFXMLNotationInfo, and CFXMLEntityInfo structures.
CFXMLNode.hA reference to a CFXMLNode object.
typedef const struct __CFXMLNode *CFXMLNodeRef;
CFXMLNode.hContains the external ID of the notation.
struct CFXMLNotationInfo {
CFXMLExternalID externalID;
};
typedef struct CFXMLNotationInfo CFXMLNotationInfo;
externalIDThe external ID of the notation.
A pointer to this structure is included in the CFXMLNode object passed to your application when the parser encounters a notation element. Use the CFXMLNodeGetInfoPtr function to obtain a pointer to this structure.
CFXMLNode.hContains the text of the processing instruction.
struct CFXMLProcessingInstructionInfo {
CFStringRef dataString;
};
typedef struct CFXMLProcessingInstructionInfo CFXMLProcessingInstructionInfo;
dataStringThe text of the processing instruction.
A pointer to this structure is included in the CFXMLNode object passed to your application when the parser encounters a processing instruction. Use the CFXMLNodeGetInfoPtr function to obtain the pointer.
CFXMLNode.hThe entity type identification codes that the parser uses to describe XML entities.
enum CFXMLEntityTypeCode { kCFXMLEntityTypeParameter = 0, kCFXMLEntityTypeParsedInternal = 1, kCFXMLEntityTypeParsedExternal = 2, kCFXMLEntityTypeUnparsed = 3, kCFXMLEntityTypeCharacter = 4 }; typedef enum CFXMLEntityTypeCode CFXMLEntityTypeCode;
kCFXMLEntityTypeParameterImplies a parsed, internal entity.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLEntityTypeParsedInternalIndicates a parsed, internal entity.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLEntityTypeParsedExternalIndicates a parsed, external entity.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLEntityTypeUnparsedIndicates an unparsed entity.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLEntityTypeCharacterIndicates a character entity type.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
These codes are used with the CFXMLEntityInfo and CFXMLEntityReferenceInfo structures.
The version of a CFXMLNode object.
enum {
kCFXMLNodeCurrentVersion = 1
};
kCFXMLNodeCurrentVersionThe current version of CFXMLNode objects.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
The various XML data type identification codes that the parser uses to describe XML structures.
enum CFXMLNodeTypeCode { kCFXMLNodeTypeDocument = 1, kCFXMLNodeTypeElement = 2, kCFXMLNodeTypeAttribute = 3, kCFXMLNodeTypeProcessingInstruction = 4, kCFXMLNodeTypeComment = 5, kCFXMLNodeTypeText = 6, kCFXMLNodeTypeCDATASection = 7, kCFXMLNodeTypeDocumentFragment = 8, kCFXMLNodeTypeEntity = 9, kCFXMLNodeTypeEntityReference = 10, kCFXMLNodeTypeDocumentType = 11, kCFXMLNodeTypeWhitespace = 12, kCFXMLNodeTypeNotation = 13, kCFXMLNodeTypeElementTypeDeclaration = 14, kCFXMLNodeTypeAttributeListDeclaration = 15 }; typedef enum CFXMLNodeTypeCode CFXMLNodeTypeCode;
kCFXMLNodeTypeDocumentIndicates a document where the data string is NULL and the additional information is a pointer to a CFXMLDocumentInfo structure.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeElementIndicates an element where the data string is the name of the tag and the additional information is a pointer to a CFXMLElementInfo structure.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeAttributeCurrently not used.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeProcessingInstructionIndicates a processing instruction where the data string is the name of the target and the additional information is a pointer to a CFXMLProcessingInstructionInfo structure.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeCommentIndicates a comment section where the data string is the text of the comment and the additional information is NULL.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeTextIndicates a text section where the data string is the text’s contents and the additional information is NULL.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeCDATASectionIndicates a CDATA section where the data string is the text of the CDATA and the additional information is NULL.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeDocumentFragmentCurrently not used.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeEntityIndicates an entity where the data string is the name of the entity and the additional information is a pointer to a CFXMLEntityInfo structure.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeEntityReferenceIndicates an entity reference where the data string is the name of the referenced entity and the additional information is a pointer to a CFXMLEntityReferenceInfo structure.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeDocumentTypeIndicates a document type where the data string is the name given to the top-level element and the additional information is a pointer to a CFXMLDocumentTypeInfo structure.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeWhitespaceIndicates white space where the data string is the text of the white space and the additional information is NULL.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeNotationIndicates a notation where the data string is the notation name and the additional information is a pointer to a CFXMLNotationInfo structure.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeElementTypeDeclarationIndicates an element type declaration where the data string is the tag name and the additional information is a pointer to a CFXMLElementTypeDeclarationInfo structure.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
kCFXMLNodeTypeAttributeListDeclarationIndicates an attribute list declaration where the data string is the tag name and the additional information is a pointer to a CFXMLAttributeListDeclarationInfo structure.
Available in Mac OS X v10.0 and later.
Declared in CFXMLNode.h.
When the parser encounters a new XML structure, its data type and contents are placed in a CFXMLNode object.
Last updated: 2006-02-07