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 -
columnNumberproperty -
lineNumberproperty -
parserErrorproperty -
publicIDproperty -
systemIDproperty
Properties
columnNumber
Returns the column number of the XML document being processed by the receiver.
@property (nonatomic, readonly) NSInteger columnNumberDiscussion
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.hlineNumber
Returns the line number of the HTML document being processed by the receiver.
@property (nonatomic, readonly) NSInteger lineNumberDiscussion
You may invoke this method once a parsing operation has begun or after an error occurs.
Declared In
DTHTMLParser.hparserError
Returns an NSError object from which you can obtain information about a parsing error.
@property (nonatomic, readonly, strong) NSError *parserErrorDiscussion
You may invoke this method after a parsing operation abnormally terminates to determine the cause of error.
Declared In
DTHTMLParser.hInstance Methods
delegate
Returns the receiver’s delegate.
- (id<DTHTMLParserDelegate>)delegateSee Also
Declared In
DTHTMLParser.hinitWithData:encoding:
Initializes the receiver with the HTML contents encapsulated in a given data object.
- (id)initWithData:(NSData *)data encoding:(NSStringEncoding)encodingParameters
- data
An
NSDataobject 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.hparse
Starts the event-driven parsing operation.
- (BOOL)parseReturn 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.hsetDelegate:
Sets the receiver’s delegate.
- (void)setDelegate:(id<DTHTMLParserDelegate>)delegateParameters
- 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