2
<!DOCTYPE gsdoc PUBLIC "-//GNUstep//DTD gsdoc 0.6.6//EN" "http://www.gnustep.org/gsdoc-0_6_6.xml">
3
<gsdoc base="GSXMLNode" next="GSXMLAttribute" up="GSXML" prev="GSXMLNamespace">
5
<title>GSXMLNode</title>
6
<author name="Michael Pakhantsov">
7
<email address="mishel@berest.dp.ua"/>
9
<author name="Richard Frith-Macdonald">
10
<email address="rfm@gnu.org"/>
12
<version>$Revision: 1.5 $</version>
13
<date>$Date: 2001/04/25 14:06:40 $</date>
17
<heading>GSXMLNode</heading>
18
<class name="GSXMLNode" super="NSObject">
19
<declared>GSXML.h</declared>
26
<method type="NSString*" factory="yes">
27
<sel>descriptionFromType:</sel>
28
<arg type="int">type</arg>
31
Return the string constant value for the node
37
<method type="int" factory="yes">
38
<sel>typeFromDescription:</sel>
39
<arg type="NSString*">desc</arg>
42
Return the numeric constant value for the node
43
type named. This method is inefficient, so the returned
44
value should be saved for re-use later. The possible
48
<item>XML_ELEMENT_NODE</item>
49
<item>XML_ATTRIBUTE_NODE</item>
50
<item>XML_TEXT_NODE</item>
51
<item>XML_CDATA_SECTION_NODE</item>
52
<item>XML_ENTITY_REF_NODE</item>
53
<item>XML_ENTITY_NODE</item>
54
<item>XML_PI_NODE</item>
55
<item>XML_COMMENT_NODE</item>
56
<item>XML_DOCUMENT_NODE</item>
57
<item>XML_DOCUMENT_TYPE_NODE</item>
58
<item>XML_DOCUMENT_FRAG_NODE</item>
59
<item>XML_NOTATION_NODE</item>
60
<item>XML_HTML_DOCUMENT_NODE</item>
61
<item>XML_DTD_NODE</item>
62
<item>XML_ELEMENT_DECL</item>
63
<item>XML_ATTRIBUTE_DECL</item>
64
<item>XML_ENTITY_DECL</item>
65
<item>XML_NAMESPACE_DECL</item>
66
<item>XML_XINCLUDE_START</item>
67
<item>XML_XINCLUDE_END</item>
68
<item>XML_SGML_DOCUMENT_NODE</item>
73
<method type="GSXMLNode*" factory="yes">
74
<sel>nodeWithNamespace:</sel>
75
<arg type="GSXMLNamespace*">ns</arg>
77
<arg type="NSString*">name</arg>
79
<arg type="NSString*">prefix</arg>
82
Creation of a new Node. This function will refuse to create a Node
83
with a similar prefix than an existing one present on this node.
90
GSXMLNode *node1, *node2;
91
NSString *prefix = @"mac-os-property";
92
NSString *href = @"http://www.gnustep.org/some/location";
94
ns = [GSXMLNamespace namespaceWithNode: nil
97
node1 = [GSXMLNode nodeWithNamespace: ns name: @"node1"];
98
node2 = [GSXMLNode nodeWithNamespace: nil name: @"node2"];
106
<sel>initWithNamespace:</sel>
107
<arg type="GSXMLNamespace*">ns</arg>
109
<arg type="NSString*">name</arg>
111
<arg type="NSString*">prefix</arg>
114
Creation of a new node elemen, ns is optional (nil).
119
<method type="GSXMLNode*" factory="yes">
121
<arg type="void*">data</arg>
124
Creation of a new Node from libxml data.
129
<method type="id" init="yes">
131
<arg type="void*">data</arg>
134
Creation of a new Node from libxml data.
139
<method type="void*">
143
Return pointer to xmlNode structure.
148
<method type="NSString*">
157
<method type="NSString*">
166
<method type="GSXMLNamespace*">
170
Return Node namespace.
175
<method type="GSXMLNamespace*">
179
Return namespace definitions of this node.
184
<method type="GSXMLAttribute*">
185
<sel>properties</sel>
188
Return pointer to the first attribute on this node.
195
n1 = [GSXMLNode nodeWithNamespace: nil name: nodeName];
196
[n1 setProp: @"prop1" value: @"value1"];
197
[n1 setProp: @"prop2" value: @"value2"];
198
[n1 setProp: @"prop3" value: @"value3"];
201
NSLog(@"n1 property name - %@ value - %@", [a name], [a value]);
202
while ((a = [a next]) != nil)
204
NSLog(@"n1 property name - %@ value - %@", [a name], [a value]);
211
<method type="NSMutableDictionary*">
212
<sel>propertiesAsDictionary</sel>
215
Return attributes and values as a dictionary.
220
NSMutableDictionary *prop;
224
prop = [n1 propertiesAsDictionary];
225
e = [prop keyEnumerator];
226
while ((key = [e nextObject]) != nil)
228
NSLog(@"property name - %@ value - %@", key,
229
[prop objectForKey: key]);
235
<method type="NSMutableDictionary*">
236
<sel>propertiesAsDictionaryWithKeyTransformationSel:</sel>
237
<arg type="SEL">keyTransformSel</arg>
240
Return attributes and values as a dictionary, but applies
241
the specified selector to each key before adding the
242
key and value to the dictionary. The selector must be a
243
method of NSString taking no arguments and returning an
244
object suitable for use as a dictionary key.
247
This method exists for the use of GSWeb ... it is probably
248
not of much use elsewhere.
253
<method type="GSXMLNodeType">
262
<method type="NSString*">
263
<sel>typeDescription</sel>
266
Return the name of the type of the Node.
271
<method type="GSXMLDocument*">
274
<p>Return owner of this node.
279
<method type="GSXMLNode*">
282
<p>Return children of this node.
285
- (GSXMLNode*) nextElement: (GSXMLNode*)node
289
if ([node type] == XML_ELEMENT_NODE)
293
if ([node children] != nil)
295
node = [self nextElement: [node children]];
306
<method type="GSXMLNode*">
309
<p>Return parent of this node.
314
<method type="GSXMLNode*">
322
<method type="GSXMLNode*">
325
<p>Return previous node.
330
<method type="GSXMLNode*">
331
<sel>makeChild:</sel>
332
<arg type="GSXMLNamespace*">ns</arg>
334
<arg type="NSString*">name</arg>
336
<arg type="NSString*">content</arg>
339
Creation of a new child element, added at the end of
340
parent children list.
341
ns and content parameters are optional (may be nil).
342
If content is non nil, a child list containing the
343
TEXTs and ENTITY_REFs node will be created.
344
Return previous node.
349
GSXMLDocument *d, *d1;
351
d = [GSXMLDocument documentWithVersion: @"1.0"];
352
[d setRoot: [d makeNodeWithNamespace: nil
355
[[d root] setProp: @"version" value: @"0.9"];
356
n1 = [[d root] makeChildWithNamespace: nil
359
[n1 makeChildWithNamespace: nil name: @"key" content: @"Year Of Birth"];
360
[n1 makeChildWithNamespace: nil name: @"integer" content: @"65"];
361
[n1 makeChildWithNamespace: nil name: @"key" content: @"Pets Names"];
362
[n1 makeChildWithNamespace: nil name: @"array" content: nil];
368
<method type="GSXMLNode*">
369
<sel>makeComment:</sel>
370
<arg type="NSString*">content</arg>
373
Creation of a new comment element, added at the end of
374
parent children list.
377
d = [GSXMLDocument documentWithVersion: @"1.0"];
379
[d setRoot: [d makeNodeWithNamespace: nil name: @"plist" content: nil]];
380
[[d root] setProp: @"version" value: @"0.9"];
381
n1 = [[d root] makeChildWithNamespace: nil name: @"dict" content: nil];
382
[n1 makeComment: @" this is a comment "];
387
<method type="GSXMLNode*">
389
<arg type="NSString*">content</arg>
392
Creation of a new process instruction element,
393
added at the end of parent children list.
396
d = [GSXMLDocument documentWithVersion: @"1.0"];
398
[d setRoot: [d makeNodeWithNamespace: nil name: @"plist" content: nil]];
399
[[d root] setProp: @"version" value: @"0.9"];
400
n1 = [[d root] makeChildWithNamespace: nil name: @"dict" content: nil];
401
[n1 makeComment: @" this is a comment "];
402
[n1 makePI: @"pi1" content: @"this is a process instruction"];
407
<method type="GSXMLAttribute*">
409
<arg type="NSString*">name</arg>
411
<arg type="NSString*">value</arg>
413
<p>Set (or reset) an attribute carried by a node.
416
id n1 = [GSXMLNode nodeWithNamespace: nil name: nodeName];
417
[n1 setProp: @"prop1" value: @"value1"];
418
[n1 setProp: @"prop2" value: @"value2"];
419
[n1 setProp: @"prop3" value: @"value3"];
429
Return the numeric type code for this node.
434
<method type="NSString*">
435
<sel>typeDescription</sel>
438
Return the string type code for this node.