-
Notifications
You must be signed in to change notification settings - Fork 229
/
Copy pathHTMLNode.h
93 lines (71 loc) · 2.04 KB
/
HTMLNode.h
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
//
// HTMLNode.h
// StackOverflow
//
// Created by Ben Reeves on 09/03/2010.
// Copyright 2010 Ben Reeves. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <libxml/HTMLparser.h>
#import "HTMLParser.h"
@class HTMLParser;
#define ParsingDepthUnlimited 0
#define ParsingDepthSame -1
#define ParsingDepth size_t
typedef enum
{
HTMLHrefNode,
HTMLTextNode,
HTMLUnkownNode,
HTMLCodeNode,
HTMLSpanNode,
HTMLPNode,
HTMLLiNode,
HTMLUlNode,
HTMLImageNode,
HTMLOlNode,
HTMLStrongNode,
HTMLPreNode,
HTMLBlockQuoteNode,
} HTMLNodeType;
@interface HTMLNode : NSObject
{
@public
xmlNode * _node;
}
//Init with a lib xml node
-(id)initWithXMLNode:(xmlNode*)xmlNode;
-(NSArray*)findChildrenOfClass:(NSString*)className;
-(HTMLNode*)findChildOfClass:(NSString*)className;
-(NSArray*)findChildrenWithAttribute:(NSString*)attribute matchingName:(NSString*)className allowPartial:(BOOL)partial;
-(HTMLNode*)findChildWithAttribute:(NSString*)attribute matchingName:(NSString*)className allowPartial:(BOOL)partial;
//Gets the attribute value matching tha name
-(NSString*)getAttributeNamed:(NSString*)name;
NSString * getAttributeNamed(xmlNode * node, const char * nameStr);
void setAttributeNamed(xmlNode * node, const char * nameStr, const char * value);
//Find childer with the specified tag name
-(NSArray*)findChildTags:(NSString*)tagName;
//Looks for a tag name e.g. "h3"
-(HTMLNode*)findChildTag:(NSString*)tagName;
//Returns the first child element
-(HTMLNode*)firstChild;
//Contents of this node and children
-(NSString*)allContents;
NSString * allNodeContents(xmlNode*node);
//Returns the contents
-(NSString*)contents;
//Returns the class name
-(NSString*)className;
//Returns the tag name
-(NSString*)tagName;
//Returns the parent
-(HTMLNode*)parent;
//Returns the contents including html tags
-(NSString*)rawContents;
NSString * rawContentsOfNode(xmlNode * node, htmlDocPtr doc);
//Returns the first level of children
-(NSArray*)children;
//Returns the node type if know
-(HTMLNodeType)nodetype;
HTMLNodeType nodeType(xmlNode* node);
@end