Mac Developer Library

Developer

CoreFoundation Framework Reference CFXMLNode Reference

Options
Deployment Target:

On This Page
Language:

CFXMLNode Reference

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.

Functions

  • Creates a new CFXMLNode.

    Declaration

    Objective-C

    CFXMLNodeRef CFXMLNodeCreate ( CFAllocatorRef alloc, CFXMLNodeTypeCode xmlType, CFStringRef dataString, const void *additionalInfoPtr, CFIndex version );

    Parameters

    alloc

    The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    xmlType

    Type identifier code for the XML structure you want this node to describe.

    dataString

    The XML data.

    additionalInfoPtr

    A pointer to a structure containing additional information about the XML data.

    version

    The version number of the CFXMLNode object you want to create. Pass one of the pre-defined constants, typically kCFXMLNodeCurrentVersion.

    Return Value

    A new CFXMLNode object. Ownership follows the Create Rule in Memory Management Programming Guide for Core Foundation.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.8.

  • Creates a copy of a CFXMLNode object.

    Declaration

    Objective-C

    CFXMLNodeRef CFXMLNodeCreateCopy ( CFAllocatorRef alloc, CFXMLNodeRef origNode );

    Parameters

    alloc

    The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    origNode

    The node to copy. Do not pass NULL.

    Return Value

    A new CFXMLNode object. Ownership follows the Create Rule in Memory Management Programming Guide for Core Foundation.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.8.

  • Returns the additional information pointer of a CFXMLNode object.

    Declaration

    Objective-C

    const void * CFXMLNodeGetInfoPtr ( CFXMLNodeRef node );

    Parameters

    node

    The CFXMLNode object to examine.

    Return Value

    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 in Memory Management Programming Guide for Core Foundation.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.8.

  • Returns the data string from a CFXMLNode.

    Declaration

    Objective-C

    CFStringRef CFXMLNodeGetString ( CFXMLNodeRef node );

    Parameters

    node

    The CFXMLNode object to examine.

    Return Value

    The data string from node. Ownership follows the Get Rule in Memory Management Programming Guide for Core Foundation.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.8.

  • Returns the XML structure type code for a CFXMLNode object.

    Declaration

    Objective-C

    CFXMLNodeTypeCode CFXMLNodeGetTypeCode ( CFXMLNodeRef node );

    Parameters

    node

    The CFXMLNode object to examine.

    Return Value

    The type code for node.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.8.

  • Returns the type identifier code for the CFXMLNode opaque type.

    Declaration

    Objective-C

    CFTypeID CFXMLNodeGetTypeID ( void );

    Return Value

    The type identifier for the CFXMLNode opaque type.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.8.

  • Returns the version number for a CFXMLNode object.

    Declaration

    Objective-C

    CFIndex CFXMLNodeGetVersion ( CFXMLNodeRef node );

    Parameters

    node

    The CFXMLNode object to examine.

    Return Value

    The version number of node.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.8.

Data Types

Miscellaneous

  • Contains information about an element attribute definition.

    Declaration

    Swift

    struct CFXMLAttributeDeclarationInfo { var attributeName: Unmanaged<CFString>! var typeString: Unmanaged<CFString>! var defaultString: Unmanaged<CFString>! }

    Objective-C

    struct CFXMLAttributeDeclarationInfo { CFStringRef attributeName; CFStringRef typeString; CFStringRef defaultString; }; typedef struct CFXMLAttributeDeclarationInfo CFXMLAttributeDeclarationInfo;

    Fields

    attributeName

    The name of the attribute.

    typeString

    Describes the declaration of a single attribute.

    defaultString

    The attribute's default value.

    Discussion

    This structure is part of the definition of the CFXMLAttributeListDeclarationInfo structure.

    Availability

    Available in OS X v10.0 and later.

  • Contains a list of the attributes associated with an element.

    Declaration

    Swift

    struct CFXMLAttributeListDeclarationInfo { var numberOfAttributes: CFIndex var attributes: UnsafeMutablePointer<CFXMLAttributeDeclarationInfo> }

    Objective-C

    struct CFXMLAttributeListDeclarationInfo { CFIndex numberOfAttributes; CFXMLAttributeDeclarationInfo *attributes; }; typedef struct CFXMLAttributeListDeclarationInfo CFXMLAttributeListDeclarationInfo;

    Fields

    numberOfAttributes

    The number of attributes in the array.

    attributes

    A C array of attributes.

    Discussion

    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.

    Availability

    Available in OS X v10.0 and later.

  • Contains the source URL and text encoding information for the XML document.

    Declaration

    Swift

    struct CFXMLDocumentInfo { var sourceURL: Unmanaged<CFURL>! var encoding: CFStringEncoding }

    Objective-C

    struct CFXMLDocumentInfo { CFURLRef sourceURL; CFStringEncoding encoding; }; typedef struct CFXMLDocumentInfo CFXMLDocumentInfo;

    Fields

    sourceURL

    The source URL of the XML document.

    encoding

    The text encoding of the XML document.

    Discussion

    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.

    Availability

    Available in OS X v10.0 and later.

  • Contains the external ID of the DTD.

    Declaration

    Swift

    struct CFXMLDocumentTypeInfo { var externalID: CFXMLExternalID }

    Objective-C

    struct CFXMLDocumentTypeInfo { CFXMLExternalID externalID; }; typedef struct CFXMLDocumentTypeInfo CFXMLDocumentTypeInfo;

    Fields

    externalID

    The external ID of the DTD.

    Discussion

    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.

    Availability

    Available in OS X v10.0 and later.

  • Contains a list of element attributes packaged as CFDictionary key/value pairs.

    Declaration

    Swift

    struct CFXMLElementInfo { var attributes: Unmanaged<CFDictionary>! var attributeOrder: Unmanaged<CFArray>! var isEmpty: Boolean var _reserved: (Int8, Int8, Int8) }

    Objective-C

    struct CFXMLElementInfo { CFDictionaryRef attributes; CFArrayRef attributeOrder; Boolean isEmpty; }; typedef struct CFXMLElementInfo CFXMLElementInfo;

    Fields

    attributes

    The dictionary of attribute values.

    attributeOrder

    An array specifying the order in which the attributes appeared in the XML document.

    isEmpty

    A flag indicating whether the element was expressed in closed form.

    Discussion

    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.

    Availability

    Available in OS X v10.0 and later.

  • Contains a description of the element type.

    Declaration

    Swift

    struct CFXMLElementTypeDeclarationInfo { var contentDescription: Unmanaged<CFString>! }

    Objective-C

    struct CFXMLElementTypeDeclarationInfo { CFStringRef contentDescription; }; typedef struct CFXMLElementTypeDeclarationInfo CFXMLElementTypeDeclarationInfo;

    Fields

    contentDescription

    A textual description of the element type.

    Discussion

    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.

    Availability

    Available in OS X v10.0 and later.

  • Contains information describing an XML entity.

    Declaration

    Swift

    struct CFXMLEntityInfo { var entityType: CFXMLEntityTypeCode var replacementText: Unmanaged<CFString>! var entityID: CFXMLExternalID var notationName: Unmanaged<CFString>! }

    Objective-C

    struct CFXMLEntityInfo { CFXMLEntityTypeCode entityType; CFStringRef replacementText; CFXMLExternalID entityID; CFStringRef notationName; }; typedef struct CFXMLEntityInfo CFXMLEntityInfo;

    Fields

    entityType

    The entity type code.

    replacementText

    NULL if entityType is external or unparsed, otherwise the text that the entity should be replaced with.

    entityID

    entityID.systemID will be NULL if entityType is internal.

    notationName

    NULL if entityType is parsed.

    Discussion

    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.

    Availability

    Available in OS X v10.0 and later.

  • Contains information describing an XML entity reference.

    Declaration

    Swift

    struct CFXMLEntityReferenceInfo { var entityType: CFXMLEntityTypeCode }

    Objective-C

    struct CFXMLEntityReferenceInfo { CFXMLEntityTypeCode entityType; }; typedef struct CFXMLEntityReferenceInfo CFXMLEntityReferenceInfo;

    Fields

    entityType

    The entity type code.

    Discussion

    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.

    Availability

    Available in OS X v10.0 and later.

  • Contains the system and public IDs for an external entity reference.

    Declaration

    Swift

    struct CFXMLExternalID { var systemID: Unmanaged<CFURL>! var publicID: Unmanaged<CFString>! }

    Objective-C

    struct CFXMLExternalID { CFURLRef systemID; CFStringRef publicID; }; typedef struct CFXMLExternalID CFXMLExternalID;

    Fields

    systemID

    The systemID URL.

    publicID

    The publicID string.

    Discussion

    This structure is part of the definition of the CFXMLDocumentTypeInfo, CFXMLNotationInfo, and CFXMLEntityInfo structures.

    Availability

    Available in OS X v10.0 and later.

  • A reference to a CFXMLNode object.

    Declaration

    Swift

    typealias CFXMLNodeRef = CFXMLNode

    Objective-C

    typedef const struct __CFXMLNode *CFXMLNodeRef;

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Contains the external ID of the notation.

    Declaration

    Swift

    struct CFXMLNotationInfo { var externalID: CFXMLExternalID }

    Objective-C

    struct CFXMLNotationInfo { CFXMLExternalID externalID; }; typedef struct CFXMLNotationInfo CFXMLNotationInfo;

    Fields

    externalID

    The external ID of the notation.

    Discussion

    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.

    Availability

    Available in OS X v10.0 and later.

  • Contains the text of the processing instruction.

    Declaration

    Swift

    struct CFXMLProcessingInstructionInfo { var dataString: Unmanaged<CFString>! }

    Objective-C

    struct CFXMLProcessingInstructionInfo { CFStringRef dataString; }; typedef struct CFXMLProcessingInstructionInfo CFXMLProcessingInstructionInfo;

    Fields

    dataString

    The text of the processing instruction.

    Discussion

    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.

    Availability

    Available in OS X v10.0 and later.

Constants

Miscellaneous

  • The entity type identification codes that the parser uses to describe XML entities.

    Declaration

    Swift

    enum CFXMLEntityTypeCode : CFIndex { case Parameter case ParsedInternal case ParsedExternal case Unparsed case Character }

    Objective-C

    enum CFXMLEntityTypeCode { kCFXMLEntityTypeParameter = 0, kCFXMLEntityTypeParsedInternal = 1, kCFXMLEntityTypeParsedExternal = 2, kCFXMLEntityTypeUnparsed = 3, kCFXMLEntityTypeCharacter = 4 }; typedef enum CFXMLEntityTypeCode CFXMLEntityTypeCode;

    Constants

    • Parameter

      kCFXMLEntityTypeParameter

      Implies a parsed, internal entity.

      Available in OS X v10.0 and later.

    • ParsedInternal

      kCFXMLEntityTypeParsedInternal

      Indicates a parsed, internal entity.

      Available in OS X v10.0 and later.

    • ParsedExternal

      kCFXMLEntityTypeParsedExternal

      Indicates a parsed, external entity.

      Available in OS X v10.0 and later.

    • Unparsed

      kCFXMLEntityTypeUnparsed

      Indicates an unparsed entity.

      Available in OS X v10.0 and later.

    • Character

      kCFXMLEntityTypeCharacter

      Indicates a character entity type.

      Available in OS X v10.0 and later.

    Discussion

    These codes are used with the CFXMLEntityInfo and CFXMLEntityReferenceInfo structures.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • The version of a CFXMLNode object.

    Declaration

    Swift

    var kCFXMLNodeCurrentVersion: Int { get }

    Objective-C

    enum { kCFXMLNodeCurrentVersion = 1 };

    Constants

    • kCFXMLNodeCurrentVersion

      kCFXMLNodeCurrentVersion

      The current version of CFXMLNode objects.

      Available in OS X v10.0 and later.

    Import Statement

  • The various XML data type identification codes that the parser uses to describe XML structures.

    Declaration

    Swift

    enum CFXMLNodeTypeCode : CFIndex { case Document case Element case Attribute case ProcessingInstruction case Comment case Text case CDATASection case DocumentFragment case Entity case EntityReference case DocumentType case Whitespace case Notation case ElementTypeDeclaration case AttributeListDeclaration }

    Objective-C

    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;

    Constants

    • Document

      kCFXMLNodeTypeDocument

      Indicates a document where the data string is NULL and the additional information is a pointer to a CFXMLDocumentInfo structure.

      Available in OS X v10.0 and later.

    • Element

      kCFXMLNodeTypeElement

      Indicates 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 OS X v10.0 and later.

    • Attribute

      kCFXMLNodeTypeAttribute

      Currently not used.

      Available in OS X v10.0 and later.

    • ProcessingInstruction

      kCFXMLNodeTypeProcessingInstruction

      Indicates 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 OS X v10.0 and later.

    • Comment

      kCFXMLNodeTypeComment

      Indicates a comment section where the data string is the text of the comment and the additional information is NULL.

      Available in OS X v10.0 and later.

    • Text

      kCFXMLNodeTypeText

      Indicates a text section where the data string is the text’s contents and the additional information is NULL.

      Available in OS X v10.0 and later.

    • CDATASection

      kCFXMLNodeTypeCDATASection

      Indicates a CDATA section where the data string is the text of the CDATA and the additional information is NULL.

      Available in OS X v10.0 and later.

    • DocumentFragment

      kCFXMLNodeTypeDocumentFragment

      Currently not used.

      Available in OS X v10.0 and later.

    • Entity

      kCFXMLNodeTypeEntity

      Indicates 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 OS X v10.0 and later.

    • EntityReference

      kCFXMLNodeTypeEntityReference

      Indicates 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 OS X v10.0 and later.

    • DocumentType

      kCFXMLNodeTypeDocumentType

      Indicates 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 OS X v10.0 and later.

    • Whitespace

      kCFXMLNodeTypeWhitespace

      Indicates white space where the data string is the text of the white space and the additional information is NULL.

      Available in OS X v10.0 and later.

    • Notation

      kCFXMLNodeTypeNotation

      Indicates a notation where the data string is the notation name and the additional information is a pointer to a CFXMLNotationInfo structure.

      Available in OS X v10.0 and later.

    • ElementTypeDeclaration

      kCFXMLNodeTypeElementTypeDeclaration

      Indicates 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 OS X v10.0 and later.

    • AttributeListDeclaration

      kCFXMLNodeTypeAttributeListDeclaration

      Indicates 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 OS X v10.0 and later.

    Discussion

    When the parser encounters a new XML structure, its data type and contents are placed in a CFXMLNode object.

    Import Statement

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.