| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in Mac OS X v10.6 and later. |
| Companion guide | |
| Declared in | NSXMLParser.h |
| Related sample code |
The NSXMLParserDelegate protocol defines the optional methods implemented by delegates of NSXMLParser objects.
– parserDidStartDocument:
– parserDidEndDocument:
– parser:didStartElement:namespaceURI:qualifiedName:attributes:
– parser:didEndElement:namespaceURI:qualifiedName:
– parser:didStartMappingPrefix:toURI:
– parser:didEndMappingPrefix:
– parser:resolveExternalEntityName:systemID:
– parser:parseErrorOccurred:
– parser:validationErrorOccurred:
– parser:foundCharacters:
– parser:foundIgnorableWhitespace:
– parser:foundProcessingInstructionWithTarget:data:
– parser:foundComment:
– parser:foundCDATA:
– parser:foundAttributeDeclarationWithName:forElement:type:defaultValue:
– parser:foundElementDeclarationWithName:model:
– parser:foundExternalEntityDeclarationWithName:publicID:systemID:
– parser:foundInternalEntityDeclarationWithName:value:
– parser:foundUnparsedEntityDeclarationWithName:publicID:systemID:notationName:
– parser:foundNotationDeclarationWithName:publicID:systemID:
Sent by a parser object to its delegate when it encounters an end tag for a specific element.
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
A parser object.
A string that is the name of an element (in its end tag).
If namespace processing is turned on, contains the URI for the current namespace as a string object.
If namespace processing is turned on, contains the qualified name for the current namespace as a string object.
– parser:didStartElement:namespaceURI:qualifiedName:attributes:– setShouldProcessNamespaces: (NSXMLParser)NSXMLParser.hSent by a parser object to its delegate when a given namespace prefix goes out of scope.
- (void)parser:(NSXMLParser *)parser didEndMappingPrefix:(NSString *)prefix
A parser object.
A string that is a namespace prefix.
The parser sends this message only when namespace-prefix reporting is turned on through the setShouldReportNamespacePrefixes: method.
NSXMLParser.hSent by a parser object to its delegate when it encounters a start tag for a given element.
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
A parser object.
A string that is the name of an element (in its start tag).
If namespace processing is turned on, contains the URI for the current namespace as a string object.
If namespace processing is turned on, contains the qualified name for the current namespace as a string object..
A dictionary that contains any attributes associated with the element. Keys are the names of attributes, and values are attribute values.
NSXMLParser.hSent by a parser object to its delegate the first time it encounters a given namespace prefix, which is mapped to a URI.
- (void)parser:(NSXMLParser *)parser didStartMappingPrefix:(NSString *)prefix toURI:(NSString *)namespaceURI
A parser object.
A string that is a namespace prefix.
A string that specifies a namespace URI.
The parser object sends this message only when namespace-prefix reporting is turned on through the setShouldReportNamespacePrefixes: method.
NSXMLParser.hSent by a parser object to its delegate when it encounters a declaration of an attribute that is associated with a specific element.
- (void)parser:(NSXMLParser *)parser foundAttributeDeclarationWithName:(NSString *)attributeName forElement:(NSString *)elementName type:(NSString *)type defaultValue:(NSString *)defaultValue
An NSXMLParser object parsing XML.
A string that is the name of an attribute.
A string that is the name of an element that has the attribute attributeName.
A string, such as "ENTITY", "NOTATION", or "ID", that indicates the type of the attribute.
A string that specifies the default value of the attribute.
NSXMLParser.hSent by a parser object to its delegate when it encounters a CDATA block.
- (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock
An NSXMLParser object parsing XML.
A data object containing a block of CDATA.
Through this method the parser object passes the contents of the block to its delegate in an NSData object. The CDATA block is character data that is ignored by the parser. The encoding of the character data is UTF-8. To convert the data object to a string object, use the NSString method initWithData:encoding:.
NSXMLParser.hSent by a parser object to provide its delegate with a string representing all or part of the characters of the current element.
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
A parser object.
A string representing the complete or partial textual content of the current element.
The parser object may send the delegate several parser:foundCharacters: messages to report the characters of an element. Because string may be only part of the total character content for the current element, you should append it to the current accumulation of characters until the element changes.
NSXMLParser.hSent by a parser object to its delegate when it encounters a comment in the XML.
- (void)parser:(NSXMLParser *)parser foundComment:(NSString *)comment
An NSXMLParser object parsing XML.
A string that is a the content of a comment in the XML.
NSXMLParser.hSent by a parser object to its delegate when it encounters a declaration of an element with a given model.
- (void)parser:(NSXMLParser *)parser foundElementDeclarationWithName:(NSString *)elementName model:(NSString *)model
An NSXMLParser object parsing XML.
A string that is the name of an element.
A string that specifies a model for elementName.
NSXMLParser.hSent by a parser object to its delegate when it encounters an external entity declaration.
- (void)parser:(NSXMLParser *)parser foundExternalEntityDeclarationWithName:(NSString *)entityName publicID:(NSString *)publicID systemID:(NSString *)systemID
An NSXMLParser object parsing XML.
A string that is the name of an entity.
A string that specifies the public ID associated with entityName.
A string that specifies the system ID associated with entityName.
– parser:foundInternalEntityDeclarationWithName:value:– parser:foundUnparsedEntityDeclarationWithName:publicID:systemID:notationName:– parser:resolveExternalEntityName:systemID:NSXMLParser.hReported by a parser object to provide its delegate with a string representing all or part of the ignorable whitespace characters of the current element.
- (void)parser:(NSXMLParser *)parser foundIgnorableWhitespace:(NSString *)whitespaceString
A parser object.
A string representing all or part of the ignorable whitespace characters of the current element.
All the whitespace characters of the element (including carriage returns, tabs, and new-line characters) may not be provided through an individual invocation of this method. The parser may send the delegate several parser:foundIgnorableWhitespace: messages to report the whitespace characters of an element. You should append the characters in each invocation to the current accumulation of characters.
NSXMLParser.hSent by a parser object to the delegate when it encounters an internal entity declaration.
- (void)parser:(NSXMLParser *)parser foundInternalEntityDeclarationWithName:(NSString *)name value:(NSString *)value
An NSXMLParser object parsing XML.
A string that is the declared name of an internal entity.
A string that is the value of entity name.
– parser:foundExternalEntityDeclarationWithName:publicID:systemID:– parser:foundUnparsedEntityDeclarationWithName:publicID:systemID:notationName:NSXMLParser.hSent by a parser object to its delegate when it encounters a notation declaration.
- (void)parser:(NSXMLParser *)parser foundNotationDeclarationWithName:(NSString *)name publicID:(NSString *)publicID systemID:(NSString *)systemID
An NSXMLParser object parsing XML.
A string that is the name of the notation.
A string specifying the public ID associated with the notation name.
A string specifying the system ID associated with the notation name.
NSXMLParser.hSent by a parser object to its delegate when it encounters a processing instruction.
- (void)parser:(NSXMLParser *)parser foundProcessingInstructionWithTarget:(NSString *)target data:(NSString *)data
A parser object.
A string representing the target of a processing instruction.
A string representing the data for a processing instruction.
NSXMLParser.hSent by a parser object to its delegate when it encounters an unparsed entity declaration.
- (void)parser:(NSXMLParser *)parser foundUnparsedEntityDeclarationWithName:(NSString *)name publicID:(NSString *)publicID systemID:(NSString *)systemID notationName:(NSString *)notationName
An NSXMLParser object parsing XML.
A string that is the name of the unparsed entity in the declaration.
A string specifying the public ID associated with the entity name.
A string specifying the system ID associated with the entity name.
A string specifying a notation of the declaration of entity name.
– parser:foundExternalEntityDeclarationWithName:publicID:systemID:– parser:foundInternalEntityDeclarationWithName:value:– parser:resolveExternalEntityName:systemID:NSXMLParser.hSent by a parser object to its delegate when it encounters a fatal error.
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
A parser object.
An NSError object describing the parsing error that occurred.
When this method is invoked, parsing is stopped. For further information about the error, you can query parseError or you can send the parser a parserError message. You can also send the parser lineNumber and columnNumber messages to further isolate where the error occurred. Typically you implement this method to display information about the error to the user.
NSXMLParser.hSent by a parser object to its delegate when it encounters a given external entity with a specific system ID.
- (NSData *)parser:(NSXMLParser *)parser resolveExternalEntityName:(NSString *)entityName systemID:(NSString *)systemID
A parser object.
A string that specifies the external name of an entity.
A string that specifies the system ID for the external entity.
An NSData object that contains the resolution of the given external entity.
The delegate can resolve the external entity (for example, locating and reading an externally declared DTD) and provide the result to the parser object as an NSData object.
– parser:foundExternalEntityDeclarationWithName:publicID:systemID:– parser:foundUnparsedEntityDeclarationWithName:publicID:systemID:notationName:NSXMLParser.hSent by a parser object to its delegate when it encounters a fatal validation error. NSXMLParser currently does not invoke this method and does not perform validation.
- (void)parser:(NSXMLParser *)parser validationErrorOccurred:(NSError *)validError
A parser object.
An NSError object describing the validation error that occurred.
If you want to validate an XML document, use the validation features of the NSXMLDocument class.
NSXMLParser.hSent by the parser object to the delegate when it has successfully completed parsing.
- (void)parserDidEndDocument:(NSXMLParser *)parser
A parser object.
NSXMLParser.hSent by the parser object to the delegate when it begins parsing a document.
- (void)parserDidStartDocument:(NSXMLParser *)parser
A parser object.
NSXMLParser.hLast updated: 2009-04-18