Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tag: 1.0
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (20 sloc) 1.083 kB


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:

ARC Support

This branch supports (and requires) Automatic Reference Counting (ARC)

Jump to Line
Something went wrong with that request. Please try again.