DTHTMLParser Class Reference
Inherits from | NSObject |
Declared in | DTHTMLParser.h |
Overview
Instances of this class parse HTML documents (including DTD declarations) in an event-driven manner. A DTHTMLParser notifies its delegate about the items (elements, attributes, CDATA blocks, comments, and so on) that it encounters as it processes an HTML document. It does not itself do anything with those parsed items except report them. It also reports parsing errors. For convenience, an DTHTMLParser object in the following descriptions is sometimes referred to as a parser object.
Tasks
Initializing a Parser Object
Parsing
-
– parse
-
– abortParsing
-
– setDelegate:
-
– delegate
-
columnNumber
property -
lineNumber
property -
parserError
property -
publicID
property -
systemID
property
Properties
columnNumber
Returns the column number of the XML document being processed by the receiver.
@property (nonatomic, readonly) NSInteger columnNumber
Discussion
The column refers to the nesting level of the HTML elements in the document. You may invoke this method once a parsing operation has begun or after an error occurs.
Declared In
DTHTMLParser.h
lineNumber
Returns the line number of the HTML document being processed by the receiver.
@property (nonatomic, readonly) NSInteger lineNumber
Discussion
You may invoke this method once a parsing operation has begun or after an error occurs.
Declared In
DTHTMLParser.h
parserError
Returns an NSError
object from which you can obtain information about a parsing error.
@property (nonatomic, readonly, strong) NSError *parserError
Discussion
You may invoke this method after a parsing operation abnormally terminates to determine the cause of error.
Declared In
DTHTMLParser.h
Instance Methods
delegate
Returns the receiver’s delegate.
- (id<DTHTMLParserDelegate>)delegate
See Also
Declared In
DTHTMLParser.h
initWithData:encoding:
Initializes the receiver with the HTML contents encapsulated in a given data object.
- (id)initWithData:(NSData *)data encoding:(NSStringEncoding)encoding
Parameters
- data
An
NSData
object containing XML markup.
- encoding
The encoding used for encoding the HTML data
Return Value
An initialized DTHTMLParser
object or nil if an error occurs.
Declared In
DTHTMLParser.h
parse
Starts the event-driven parsing operation.
- (BOOL)parse
Return Value
YES
if parsing is successful and NO
in there is an error or if the parsing operation is aborted.
Discussion
If you invoke this method, the delegate, if it implements parser:parseErrorOccurred:, is informed of the cancelled parsing operation.
Declared In
DTHTMLParser.h
setDelegate:
Sets the receiver’s delegate.
- (void)setDelegate:(id<DTHTMLParserDelegate>)delegate
Parameters
- delegate
An object that is the new delegate. It is not retained. The delegate must conform to the DTHTMLParserDelegate Protocol protocol.
See Also
Declared In
DTHTMLParser.h