Permalink
Browse files

Added code sample to README. Updated Xcode project for 4.3.

  • Loading branch information...
1 parent 5852d4c commit 269f55b607ef778ec5c36dae950cff1632c982a0 @nfarina committed Feb 25, 2012
Showing with 22 additions and 1 deletion.
  1. +21 −0 README.md
  2. +1 −1 XMLDocumentSamples/XMLDocumentSamples.xcodeproj/project.pbxproj
View
@@ -3,6 +3,27 @@
SMXMLDocument is a very handy lightweight XML parser for iOS.
+In brief:
+
+ // create a new SMXMLDocument with the contents of sample.xml
+ SMXMLDocument *document = [SMXMLDocument documentWithData:data error:&error];
+
+ // Pull out the <books> node
+ SMXMLElement *books = [document.root childNamed:@"books"];
+
+ // Look through <books> children of type <book>
+ for (SMXMLElement *book in [books childrenNamed:@"book"]) {
+
+ // demonstrate common cases of extracting XML data
+ NSString *isbn = [book attributeNamed:@"isbn"]; // XML attribute
+ NSString *title = [book valueWithPath:@"title"]; // child node value
+
+ // show off some KVC magic
+ NSArray *authors = [[book childNamed:@"authors"].children valueForKey:@"value"];
+
+ // do interesting things...
+ }
+
More info in the blog post:
http://nfarina.com/post/2843708636/a-lightweight-xml-parser-for-ios
@@ -122,7 +122,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0420;
+ LastUpgradeCheck = 0430;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "XMLDocumentSamples" */;
compatibilityVersion = "Xcode 3.2";

0 comments on commit 269f55b

Please sign in to comment.