Type Method

replacementClassForClass:

Overridden by subclasses to substitute a custom class for an NSXML class that the parser uses to create node instances.

Declaration

+ (Class)replacementClassForClass:(Class)cls;

Parameters

class

A Class object identifying an NSXML class that is to be replaced by your custom class.

Return Value

The substituted class.

Discussion

For example, if you have a custom subclass of NSXMLElement that you want to be used in place of NSXMLElement, you would make the following override:

+ (Class)replacementClassForClass:(Class)currentClass {
    if ( currentClass == [NSXMLElement class] ) {
        return [MyCustomElementClass class];
    }
}

This method is invoked before a document is parsed. The substituted class must be a subclass of NSXMLNode, NSXMLDocument, NSXMLElement, NSXMLDTD, or NSXMLDTDNode.

See Also

Initializing NSXMLDocument Objects

- initWithContentsOfURL:options:error:

Initializes and returns an NSXMLDocument object created from the XML or HTML contents of a URL-referenced source

- initWithData:options:error:

Initializes and returns an NSXMLDocument object created from an NSData object.

- initWithRootElement:

Returns an NSXMLDocument object initialized with a single child, the root element.

- initWithXMLString:options:error:

Initializes and returns an NSXMLDocument object created from a string containing XML markup text.