@@ -5,28 +5,28 @@ SMXMLDocument is a very handy lightweight XML parser for iOS.
5
5
6
6
In brief:
7
7
8
- // create a new SMXMLDocument with the contents of sample.xml
9
- SMXMLDocument * document = [ SMXMLDocument documentWithData: data error:&error] ;
10
-
11
- // Pull out the <books > node
12
- SMXMLElement * books = [ document.root childNamed:@"books"] ;
13
-
14
- // Look through <books > children of type <book >
15
- for (SMXMLElement * book in [ books childrenNamed:@"book"] ) {
16
-
17
- // demonstrate common cases of extracting XML data
18
- NSString * isbn = [ book attributeNamed:@"isbn"] ; // XML attribute
19
- NSString * title = [ book valueWithPath:@"title"] ; // child node value
20
-
21
- // show off some KVC magic
22
- NSArray * authors = [[ book childNamed:@"authors"] .children valueForKey:@"value"] ;
23
-
24
- // do interesting things...
25
- }
8
+ // create a new SMXMLDocument with the contents of sample.xml
9
+ SMXMLDocument *document = [SMXMLDocument documentWithData:data error:&error];
10
+
11
+ // Pull out the <books> node
12
+ SMXMLElement *books = [document.root childNamed:@"books"];
13
+
14
+ // Look through <books> children of type <book>
15
+ for (SMXMLElement *book in [books childrenNamed:@"book"]) {
16
+
17
+ // demonstrate common cases of extracting XML data
18
+ NSString *isbn = [book attributeNamed:@"isbn"]; // XML attribute
19
+ NSString *title = [book valueWithPath:@"title"]; // child node value
20
+
21
+ // show off some KVC magic
22
+ NSArray *authors = [[book childNamed:@"authors"].children valueForKey:@"value"];
23
+
24
+ // do interesting things...
25
+ }
26
26
27
27
More info in the blog post:
28
28
http://nfarina.com/post/2843708636/a-lightweight-xml-parser-for-ios
29
29
30
30
### ARC Support
31
31
32
- This branch supports (and requires) [ Automatic Reference Counting (ARC)] ( http://clang.llvm.org/docs/AutomaticReferenceCounting.html )
32
+ This branch supports (and requires) [ Automatic Reference Counting (ARC)] ( http://clang.llvm.org/docs/AutomaticReferenceCounting.html )
0 commit comments