Skip to content

Commit

Permalink
Added code sample to README. Updated Xcode project for 4.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
nfarina committed Feb 25, 2012
1 parent 5c9cc3a commit 37ad8e4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,9 +3,30 @@


SMXMLDocument is a very handy lightweight XML parser for iOS. 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: More info in the blog post:
http://nfarina.com/post/2843708636/a-lightweight-xml-parser-for-ios http://nfarina.com/post/2843708636/a-lightweight-xml-parser-for-ios


### ARC Support ### ARC Support


Try the [master_arc](https://github.com/nfarina/xmldocument/tree/master_arc) branch if your project has [Automatic Reference Counting (ARC)](http://clang.llvm.org/docs/AutomaticReferenceCounting.html) enabled. Try the [master_arc](https://github.com/nfarina/xmldocument/tree/master_arc) branch if your project has [Automatic Reference Counting (ARC)](http://clang.llvm.org/docs/AutomaticReferenceCounting.html) enabled.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 45; objectVersion = 46;
objects = { objects = {


/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
Expand Down Expand Up @@ -121,8 +121,11 @@
/* Begin PBXProject section */ /* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = { 29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = {
LastUpgradeCheck = 0430;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "XMLDocumentSamples" */; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "XMLDocumentSamples" */;
compatibilityVersion = "Xcode 3.1"; compatibilityVersion = "Xcode 3.2";
developmentRegion = English; developmentRegion = English;
hasScannedForEncodings = 1; hasScannedForEncodings = 1;
knownRegions = ( knownRegions = (
Expand Down Expand Up @@ -201,7 +204,6 @@
GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
}; };
Expand All @@ -217,7 +219,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PREBINDING = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
}; };
Expand Down

0 comments on commit 37ad8e4

Please sign in to comment.