NSXMLParserDelegate Protocol Reference
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in OS X v10.6 and later. |
| Companion guide | |
| Declared in | NSXMLParser.h |
Overview
The NSXMLParserDelegate protocol defines the optional methods implemented by delegates of NSXMLParser objects.
Tasks
Handling XML
-
– 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:
Handling the DTD
-
– parser:foundAttributeDeclarationWithName:forElement:type:defaultValue: -
– parser:foundElementDeclarationWithName:model: -
– parser:foundExternalEntityDeclarationWithName:publicID:systemID: -
– parser:foundInternalEntityDeclarationWithName:value: -
– parser:foundUnparsedEntityDeclarationWithName:publicID:systemID:notationName: -
– parser:foundNotationDeclarationWithName:publicID:systemID:
Instance Methods
parser:didEndElement:namespaceURI:qualifiedName:
Sent by a parser object to its delegate when it encounters an end tag for a specific element.
Parameters
- parser
A parser object.
- elementName
A string that is the name of an element (in its end tag).
- namespaceURI
If namespace processing is turned on, contains the URI for the current namespace as a string object.
- qName
If namespace processing is turned on, contains the qualified name for the current namespace as a string object.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSXMLParser.hparser:didEndMappingPrefix:
Sent by a parser object to its delegate when a given namespace prefix goes out of scope.
Parameters
- parser
A parser object.
- prefix
A string that is a namespace prefix.
Discussion
The parser sends this message only when namespace-prefix reporting is turned on through the setShouldReportNamespacePrefixes: method.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSXMLParser.hparser:didStartElement:namespaceURI:qualifiedName:attributes:
Sent by a parser object to its delegate when it encounters a start tag for a given element.
Parameters
- parser
A parser object.
- elementName
A string that is the name of an element (in its start tag).
- namespaceURI
If namespace processing is turned on, contains the URI for the current namespace as a string object.
- qualifiedName
If namespace processing is turned on, contains the qualified name for the current namespace as a string object..
- attributeDict
A dictionary that contains any attributes associated with the element. Keys are the names of attributes, and values are attribute values.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSXMLParser.hparser:didStartMappingPrefix:toURI:
Sent by a parser object to its delegate the first time it encounters a given namespace prefix, which is mapped to a URI.
Parameters
- parser
A parser object.
- prefix
A string that is a namespace prefix.
- namespaceURI
A string that specifies a namespace URI.
Discussion
The parser object sends this message only when namespace-prefix reporting is turned on through the setShouldReportNamespacePrefixes: method.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSXMLParser.hparser:foundAttributeDeclarationWithName:forElement:type:defaultValue:
Sent by a parser object to its delegate when it encounters a declaration of an attribute that is associated with a specific element.
Parameters
- parser
An
NSXMLParserobject parsing XML.- attributeName
A string that is the name of an attribute.
- elementName
A string that is the name of an element that has the attribute attributeName.
- type
A string, such as "ENTITY", "NOTATION", or "ID", that indicates the type of the attribute.
- defaultValue
A string that specifies the default value of the attribute.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSXMLParser.hparser:foundCDATA:
Sent by a parser object to its delegate when it encounters a CDATA block.
Parameters
- parser
An
NSXMLParserobject parsing XML.- CDATABlock
A data object containing a block of CDATA.
Discussion
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:.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSXMLParser.hparser:foundCharacters:
Sent by a parser object to provide its delegate with a string representing all or part of the characters of the current element.
Parameters
- parser
A parser object.
- string
A string representing the complete or partial textual content of the current element.
Discussion
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.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSXMLParser.hparser:foundComment:
Sent by a parser object to its delegate when it encounters a comment in the XML.
Parameters
- parser
An
NSXMLParserobject parsing XML.- comment
A string that is a the content of a comment in the XML.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSXMLParser.hparser:foundElementDeclarationWithName:model:
Sent by a parser object to its delegate when it encounters a declaration of an element with a given model.
Parameters
- parser
An
NSXMLParserobject parsing XML.- elementName
A string that is the name of an element.
- model
A string that specifies a model for elementName.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSXMLParser.hparser:foundExternalEntityDeclarationWithName:publicID:systemID:
Sent by a parser object to its delegate when it encounters an external entity declaration.
Parameters
- parser
An
NSXMLParserobject parsing XML.- entityName
A string that is the name of an entity.
- publicID
A string that specifies the public ID associated with entityName.
- systemID
A string that specifies the system ID associated with entityName.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSXMLParser.hparser:foundIgnorableWhitespace:
Reported by a parser object to provide its delegate with a string representing all or part of the ignorable whitespace characters of the current element.
Parameters
- parser
A parser object.
- whitespaceString
A string representing all or part of the ignorable whitespace characters of the current element.
Discussion
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.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSXMLParser.hparser:foundInternalEntityDeclarationWithName:value:
Sent by a parser object to the delegate when it encounters an internal entity declaration.
Parameters
- parser
An
NSXMLParserobject parsing XML.- name
A string that is the declared name of an internal entity.
- value
A string that is the value of entity name.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSXMLParser.hparser:foundNotationDeclarationWithName:publicID:systemID:
Sent by a parser object to its delegate when it encounters a notation declaration.
Parameters
- parser
An
NSXMLParserobject parsing XML.- name
A string that is the name of the notation.
- publicID
A string specifying the public ID associated with the notation name.
- systemID
A string specifying the system ID associated with the notation name.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSXMLParser.hparser:foundProcessingInstructionWithTarget:data:
Sent by a parser object to its delegate when it encounters a processing instruction.
Parameters
- parser
A parser object.
- target
A string representing the target of a processing instruction.
- data
A string representing the data for a processing instruction.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSXMLParser.hparser:foundUnparsedEntityDeclarationWithName:publicID:systemID:notationName:
Sent by a parser object to its delegate when it encounters an unparsed entity declaration.
Parameters
- parser
An
NSXMLParserobject parsing XML.- name
A string that is the name of the unparsed entity in the declaration.
- publicID
A string specifying the public ID associated with the entity name.
- systemID
A string specifying the system ID associated with the entity name.
- notationName
A string specifying a notation of the declaration of entity name.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSXMLParser.hparser:parseErrorOccurred:
Sent by a parser object to its delegate when it encounters a fatal error.
Parameters
- parser
A parser object.
- parseError
An
NSErrorobject describing the parsing error that occurred.
Discussion
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.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSXMLParser.hparser:resolveExternalEntityName:systemID:
Sent by a parser object to its delegate when it encounters a given external entity with a specific system ID.
Parameters
- parser
A parser object.
- entityName
A string that specifies the external name of an entity.
- systemID
A string that specifies the system ID for the external entity.
Return Value
An NSData object that contains the resolution of the given external entity.
Discussion
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.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSXMLParser.hparser:validationErrorOccurred:
Sent 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.
Parameters
- parser
A parser object.
- validError
An
NSErrorobject describing the validation error that occurred.
Discussion
If you want to validate an XML document, use the validation features of the NSXMLDocument class.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSXMLParser.hparserDidEndDocument:
Sent by the parser object to the delegate when it has successfully completed parsing.
Parameters
- parser
A parser object.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSXMLParser.hparserDidStartDocument:
Sent by the parser object to the delegate when it begins parsing a document.
Parameters
- parser
A parser object.
Availability
- Available in OS X v10.3 and later.
- Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSXMLParser.h© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-04-23)