@@ -140,6 +140,62 @@ - (NSXMLElement *)elementForName:(NSString *)name xmlnsPrefix:(NSString *)xmlnsP
140
140
return result;
141
141
}
142
142
143
+ /* *
144
+ * This method removes the first child element for the given name.
145
+ * If no child elements exist for the given name, this method does nothing.
146
+ **/
147
+ - (void )removeElementForName : (NSString *)name
148
+ {
149
+ NSXMLElement *element = [self elementForName: name];
150
+
151
+ if (element)
152
+ {
153
+ [self removeChildAtIndex: [[self children ] indexOfObject: element]];
154
+ }
155
+ }
156
+
157
+ /* *
158
+ * This method removes the all child elements for the given name.
159
+ * If no child elements exist for the given name, this method does nothing.
160
+ **/
161
+ - (void )removeElementsForName : (NSString *)name
162
+ {
163
+ NSArray *elements = [self elementsForName: name];
164
+
165
+ for (NSXMLElement *element in elements)
166
+ {
167
+ [self removeChildAtIndex: [[self children ] indexOfObject: element]];
168
+ }
169
+ }
170
+
171
+ /* *
172
+ * This method removes the first child element for the given name and given xmlns.
173
+ * If no child elements exist for the given name and given xmlns, this method does nothing.
174
+ **/
175
+ - (void )removeElementForName : (NSString *)name xmlns : (NSString *)xmlns
176
+ {
177
+ NSXMLElement *element = [self elementForName: name xmlns: xmlns];
178
+
179
+ if (element)
180
+ {
181
+ [self removeChildAtIndex: [[self children ] indexOfObject: element]];
182
+ }
183
+ }
184
+
185
+ /* *
186
+ * This method removes the first child element for the given name and given xmlns prefix.
187
+ * If no child elements exist for the given name and given xmlns prefix, this method does nothing.
188
+ **/
189
+ - (void )removeElementForName : (NSString *)name xmlnsPrefix : (NSString *)xmlnsPrefix
190
+ {
191
+ NSXMLElement *element = [self elementForName: name xmlnsPrefix: xmlnsPrefix];
192
+
193
+ if (element)
194
+ {
195
+ [self removeChildAtIndex: [[self children ] indexOfObject: element]];
196
+ }
197
+ }
198
+
143
199
/* *
144
200
* Returns the common xmlns "attribute", which is only accessible via the namespace methods.
145
201
* The xmlns value is often used in jabber elements.
0 commit comments