forked from stklieme/HTMLDocument
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHTMLDocument.h
More file actions
executable file
·211 lines (177 loc) · 12.6 KB
/
Copy pathHTMLDocument.h
File metadata and controls
executable file
·211 lines (177 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*###################################################################################
# #
# HTMLDocument.h #
# #
# Copyright © 2011-2013 by Stefan Klieme #
# #
# Objective-C wrapper for HTML parser of libxml2 #
# #
# Version 1.6 - 29. Sep 2013 #
# #
# usage: add libxml2.dylib to frameworks #
# add $SDKROOT/usr/include/libxml2 to target -> Header Search Paths #
# add -lxml2 to target -> other linker flags #
# #
# #
####################################################################################
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy of #
# this software and associated documentation files (the "Software"), to deal #
# in the Software without restriction, including without limitation the rights #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies #
# of the Software, and to permit persons to whom the Software is furnished to do #
# so, subject to the following conditions: #
# The above copyright notice and this permission notice shall be included in #
# all copies or substantial portions of the Software. #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,#
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR #
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #
# #
###################################################################################*/
#import <Foundation/Foundation.h>
#import <libxml/HTMLparser.h>
#import "HTMLNode.h"
@interface HTMLDocument : NSObject
{
htmlDocPtr htmlDoc_;
HTMLNode *rootNode;
}
// convenience initializer methods
// default text encoding is UTF-8
/*! Returns an HTMLDocument object created from an NSData object with specified string encoding
* \param data A data object with HTML content
* \param encoding The string encoding for the HTML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized HTMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
+ (HTMLDocument *)documentWithData:(NSData *)data encoding:(NSStringEncoding )encoding error:(NSError **)error;
/*! Returns an HTMLDocument object created from an NSData object with assumed UTF-8 string encoding
* \param data A data object with HTML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized HTMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
+ (HTMLDocument *)documentWithData:(NSData *)data error:(NSError **)error;
/*! Returns an HTMLDocument object created from the HTML contents of a URL-referenced source with specified string encoding
* \param url An NSURL object specifying a URL source
* \param encoding The string encoding for the HTML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized HTMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
+ (HTMLDocument *)documentWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding )encoding error:(NSError **)error;
/*! Returns an HTMLDocument object created from the HTML contents of a URL-referenced source with assumed UTF-8 string encoding
* \param url An NSURL object specifying a URL source
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized HTMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
+ (HTMLDocument *)documentWithContentsOfURL:(NSURL *)url error:(NSError **)error;
/*! Returns an HTMLDocument object created from a string containing HTML markup text with specified string encoding
* \param url An NSURL object specifying a URL source
* \param encoding The string encoding for the HTML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized HTMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
+ (HTMLDocument *)documentWithHTMLString:(NSString *)string encoding:(NSStringEncoding )encoding error:(NSError **)error;
/*! Returns an HTMLDocument object created from a string containing HTML markup text with assumed UTF-8 string encoding
* \param url An NSURL object specifying a URL source
* \param encoding The string encoding for the HTML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized HTMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
+ (HTMLDocument *)documentWithHTMLString:(NSString *)string error:(NSError **)error;
/*! Initializes and returns an HTMLDocument object created from an NSData object with specified string encoding
* \param data A data object with HTML or XML content
* \param encoding The string encoding for the HTML or XML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized HTMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
- (INSTANCETYPE_OR_ID)initWithData:(NSData *)data encoding:(NSStringEncoding )encoding error:(NSError **)error; // designated initializer
/*! Initializes and returns an HTMLDocument object created from an NSData object with assumed UTF-8 string encoding
* \param data A data object with HTML or XML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized HTMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
- (INSTANCETYPE_OR_ID)initWithData:(NSData *)data error:(NSError **)error;
/*! Initializes and returns an HTMLDocument object created from the HTML or XML contents of a URL-referenced source with specified string encoding
* \param url An NSURL object specifying a URL source
* \param encoding The string encoding for the HTML or XML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized HTMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
- (INSTANCETYPE_OR_ID)initWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding )encoding error:(NSError **)error;
/*! Initializes and returns an HTMLDocument object created from the HTML or XML contents of a URL-referenced source with assumed UTF-8 string encoding
* \param url An NSURL object specifying a URL source
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized HTMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
- (INSTANCETYPE_OR_ID)initWithContentsOfURL:(NSURL *)url error:(NSError **)error;
/*! Initializes and returns an HTMLDocument object created from a string containing HTML or XML markup text with specified string encoding
* \param url An NSURL object specifying a URL source
* \param encoding The string encoding for the HTML or XML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized HTMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
- (INSTANCETYPE_OR_ID)initWithHTMLString:(NSString *)string encoding:(NSStringEncoding )encoding error:(NSError **)error;
/*! Initializes and returns an HTMLDocument object created from a string containing HTML or XML markup text with assumed UTF-8 string encoding
* \param url An NSURL object specifying a URL source
* \param encoding The string encoding for the HTML or XML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems.
* \returns An initialized HTMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
- (INSTANCETYPE_OR_ID)initWithHTMLString:(NSString *)string error:(NSError **)error;
/*! The root node*/
@property (readonly) HTMLNode *rootNode;
/*! The head node*/
@property (SAFE_ARC_READONLY_OBJ_PROP) HTMLNode *head;
/*! The body node*/
@property (SAFE_ARC_READONLY_OBJ_PROP) HTMLNode *body;
/*! The value of the title tag in the head node*/
@property (SAFE_ARC_READONLY_OBJ_PROP) NSString *title;
@end
@interface XMLDocument : HTMLDocument
{
xmlDocPtr xmlDoc_;
}
/*! Returns an XMLDocument object created from an NSData object with specified string encoding
* \param data A data object with XML content
* \param encoding The string encoding for the XML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized XMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
+ (XMLDocument *)documentWithData:(NSData *)data encoding:(NSStringEncoding )encoding error:(NSError **)error;
/*! Returns an XMLDocument object created from an NSData object with assumed UTF-8 string encoding
* \param data A data object with XML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized XMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
+ (XMLDocument *)documentWithData:(NSData *)data error:(NSError **)error;
/*! Returns an XMLDocument object created from the XML contents of a URL-referenced source with specified string encoding
* \param url An NSURL object specifying a URL source
* \param encoding The string encoding for the XML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized XMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
+ (XMLDocument *)documentWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding )encoding error:(NSError **)error;
/*! Returns an XMLDocument object created from the XML contents of a URL-referenced source with assumed UTF-8 string encoding
* \param url An NSURL object specifying a URL source
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized XMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
+ (XMLDocument *)documentWithContentsOfURL:(NSURL *)url error:(NSError **)error;
/*! Returns an XMLDocument object created from a string containing XML markup text with specified string encoding
* \param url An NSURL object specifying a URL source
* \param encoding The string encoding for the XML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized XMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
+ (XMLDocument *)documentWithHTMLString:(NSString *)string encoding:(NSStringEncoding )encoding error:(NSError **)error;
/*! Returns an XMLDocument object created from a string containing XML markup text with assumed UTF-8 string encoding
* \param url An NSURL object specifying a URL source
* \param encoding The string encoding for the XML content
* \param error An error object that, on return, identifies any parsing errors and warnings or connection problems
* \returns An initialized XMLDocument object, or nil if initialization fails because of parsing errors or other reasons
*/
+ (XMLDocument *)documentWithHTMLString:(NSString *)string error:(NSError **)error;
@end