This repository has been archived by the owner on Feb 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIGXMLNode.h
executable file
·165 lines (129 loc) · 3.11 KB
/
IGXMLNode.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
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
//
// IGXMLNode.h
// IGHTMLQuery
//
// Created by Francis Chong on 20/8/13.
// Copyright (c) 2013 Ignition Soft. All rights reserved.
//
#import <libxml2/libxml/xmlreader.h>
#import <libxml2/libxml/xmlmemory.h>
#import <libxml2/libxml/xmlerror.h>
#import <libxml/xpath.h>
#import <libxml/xpathInternals.h>
#import <Foundation/Foundation.h>
#import "IGXMLNodeSet.h"
#import "IGXMLNodeManipulation.h"
#import "IGXMLNodeQuery.h"
extern NSString* const IGXMLQueryErrorDomain;
extern NSString* const IGXMLNodeException;
@class IGXMLDocument;
@interface IGXMLNode : NSObject <IGXMLNodeManipulation, IGXMLNodeQuery, NSCopying>
/**
backed XML node,
*/
@property (nonatomic, readwrite, unsafe_unretained) xmlNodePtr node;
/**
Create a node using a libxml node
*/
- (id)initWithXMLNode:(xmlNodePtr)node;
/**
Create a node using a libxml node
*/
+ (id)nodeWithXMLNode:(xmlNodePtr)node;
/**
@return get tag name of current node.
*/
- (NSString *)tag;
/**
@param the new tag to set
*/
- (void)setTag:(NSString*)tag;
/**
@return get text of current node.
*/
- (NSString *)text;
/**
@param the new content of the node
*/
- (void) setText:(NSString*)text;
/**
@return get XML of node;
*/
- (NSString *)xml;
/**
@return get inner XML of node;
*/
- (NSString *)innerXml;
/**
@return get last error.
*/
- (NSError*) lastError;
/**
remove namespace of the document recursively.
*/
- (void)removeNamespaces;
@end
@interface IGXMLNode (Traversal)
/**
@return get parent node
*/
- (IGXMLNode *) parent;
/**
@return get next sibling node
*/
- (IGXMLNode *) nextSibling;
/**
@return get previous sibling node
*/
- (IGXMLNode *) previousSibling;
/**
@return get children elements of current node as {{IGXMLNodeSet}}.
*/
- (IGXMLNodeSet*) children;
/**
@return get first child element of current node. If no child exists, return nil.
*/
- (IGXMLNode*) firstChild;
/**
@return It returns a key guaranteed to be unique for this node, and to always be the same value for this node. In other words, two node objects return the same key if and only if isSameNode indicates that they are the same node.
*/
- (NSString*) uniqueKey;
@end
@interface IGXMLNode (Attributes)
/**
@param attName attribute name to get
@return attribute value
*/
- (NSString *)attribute:(NSString *)attName;
/**
@param attName attribute name
@param ns namespace
@return attribute value
*/
- (NSString *)attribute:(NSString *)attName inNamespace:(NSString *)ns;
/**
@param attName attribute name to set
@param value value to set
*/
- (void) setAttribute:(NSString*)attName value:(NSString*)value;
/**
@param attName attribute name to set
@param ns namespace
@param value value to set
*/
- (void) setAttribute:(NSString*)attName inNamespace:(NSString*)ns value:(NSString*)value;
/**
@param attName attribute name to remove
*/
- (void) removeAttribute:(NSString*)attName;
/**
@param attName attribute name to remove
*/
- (void) removeAttribute:(NSString*)attName inNamespace:(NSString*)ns;
- (NSArray *)attributeNames;
/**
subscript support
*/
- (id)objectForKeyedSubscript:(id)key;
- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
@end