{"issue":{"state":"open","created_at":"2011-11-29T18:00:35Z","updated_at":"2011-11-29T19:08:18Z","user":{"gravatar_id":"64a9babd6d842fac03017bc826c6e078","id":1188429,"url":"https://api.github.com/users/briomusic","avatar_url":"https://secure.gravatar.com/avatar/64a9babd6d842fac03017bc826c6e078?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"briomusic"},"comments":2,"body":"Hi, I hope this is an ok place to ask this question. So far, I have only used functions from the sample.xml that I adapted to my needs, but I have now come across a stumbling block. How do I parse the following file with SMXMLDocument? (mark up signs replaced with brackets as they wouldn't display in the preview)\r\n\r\n(?xml version=\"1.0\" encoding=\"UTF-8\"?)\r\n(results totalResults=\"74\") \r\n    (gigs)\r\n        (gig)\r\n            (venue)A-Trane, Berlin(/venue)\r\n            (date)22/10/11(/date)\r\n            (merchitems)\r\n                (merchitem)\r\n                    (articleDescription)CD Optativo(/articleDescription)\r\n                    (articlePrice)5.99(/articlePrice)\r\n                    (articleSold)4(/articleSold)\r\n                (/merchitem)\r\n                (merchitem)\r\n                (articleDescription)CD Mi Libro Abierto(/articleDescription)\r\n                    (articlePrice)6.99(/articlePrice)\r\n                    (articleSold)45(/articleSold)\r\n                (/merchitem)\r\n            (/merchitems)\r\n        (/gig)\r\n    (/gigs)\r\n(/results)\r\n\r\nI have managed to extract the 'venue' and 'date' items, but am stuck parsing the contained array 'merchitems' (which in itself contains a dictionary) into my iOS project. This is my attempt so far:\r\n\r\n    SMXMLDocument *document = [SMXMLDocument documentWithData:data error:NULL];\r\n    SMXMLElement *gigs = [document.root childNamed:@\"gigs\"];\r\n    \r\n\t// parsing loop\r\n\tfor (SMXMLElement *gig in [gigs childrenNamed:@\"gig\"]) {\r\n\t\t        \r\n\t\tNSString *venue = [gig valueWithPath:@\"venue\"]; \r\n        NSLog(@\"currently parsing venue %@\", venue);\r\n        NSMutableDictionary *gigReport = [NSMutableDictionary dictionaryWithObject:venue forKey:@\"Venue\"];\r\n\r\n        NSString *date = [gig valueWithPath:@\"date\"]; \r\n        [gigReport setObject:date forKey:@\"Date\"];\r\n        \r\n        // everything works up to here, then it goes wrong //\r\n        \r\n        SMXMLElement *merchitems = [document.root descendantWithPath:@\"merchitems\"];        \r\n        NSMutableArray *merchandiseArray = [NSMutableArray array];\r\n        for (SMXMLElement *merchitem in [merchitems childrenNamed:@\"merchitem\"]) {\r\n            \r\n            NSString *articleDesc = [merchitem valueWithPath:@\"articleDescription\"]; \r\n            NSLog(@\"currently parsing article %@\", articleDesc);\r\n\r\n            NSMutableDictionary *merchDict = [NSMutableDictionary dictionaryWithObject:articleDesc forKey:@\"Article Description\"];\r\n            \r\n            NSString *articlePric = [merchitem valueWithPath:@\"articlePrice\"];  \r\n            [merchDict setObject:[NSNumber numberWithDouble:[articlePric doubleValue]] forKey:@\"Article Price\"];\r\n\r\n            NSString *articleSol = [merchitem valueWithPath:@\"articleSold\"]; \r\n            [merchDict setObject:[NSNumber numberWithInt:[articleSol intValue]] forKey:@\"Articles Sold\"];\r\n\r\n            [merchandiseArray addObject:merchDict];\r\n        }\r\n        [gigReport setObject:merchandiseArray forKey:@\"Merchandise Form\"];\r\n        \r\n        [self.storedGigReports addObject:gigReport];\r\n    }\r\n\r\nThanks in advance for any help, hopefully one day I can give some back.\r\nbriomusic","assignee":null,"id":2389027,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[],"number":5,"title":"trying to parse deeper nested XML","closed_at":null,"html_url":"https://github.com/nfarina/xmldocument/issues/5","url":"https://api.github.com/repos/nfarina/xmldocument/issues/5","milestone":null},"action":"created","comment":{"created_at":"2011-11-29T19:08:18Z","updated_at":"2011-11-29T19:08:18Z","user":{"gravatar_id":"64a9babd6d842fac03017bc826c6e078","id":1188429,"url":"https://api.github.com/users/briomusic","avatar_url":"https://secure.gravatar.com/avatar/64a9babd6d842fac03017bc826c6e078?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"briomusic"},"body":"that did the trick, whole app is alive again :)\n\nyou, sir, are a gentleman and a scholar.\ncheers\nbrio\n\np.s. feel free to close issue as you please.\n\nOn Tue, Nov 29, 2011 at 7:56 PM, Nick Farina <\nreply@reply.github.com\n> wrote:\n\n> I think instead of:\n>\n>        SMXMLElement *merchitems = [document.root descendantWithPath:@\n> \"merchitems\"];\n>\n> You really want:\n>\n>        SMXMLElement *merchitems = [gig childNamed:@\"merchitems\"];\n>\n> ---\n> Reply to this email directly or view it on GitHub:\n> https://github.com/nfarina/xmldocument/issues/5#issuecomment-2941651\n>","id":2942261,"url":"https://api.github.com/repos/nfarina/xmldocument/issues/comments/2942261"}}