I have a XML file in the documents directory that I am trying to parse (to display in a table view).
<tickets>
<ticket>
<tid>11111</tid>
<status>Open</status>
<summary>Summary 1</summary> //want to grab this
<notes>Notes 1</notes>
</ticket>
<ticket>
<tid>11112</tid>
<status>Open</status>
<summary>Summary 2</summary> //want to grab this
<notes>Notes 2</notes>
</ticket>
...
</tickets>
I would like summary to be displayed in the table view. For now, I am just trying to get a NSMutableArray filled with all of the summary strings.
I am using XMLReader to create a dictionary of everything. I then use the following code to try to get to summary.
NSData *data = [NSData dataWithContentsOfFile:save];
NSString *xml = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
// Parse the XML into a dictionary
NSError *parseError;
NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLString:xml error:&parseError];
NSDictionary *ticketsArray = [xmlDictionary objectForKey:@"tickets"];
NSDictionary *ticketArray = [ticketsArray objectForKey:@"ticket"];;
//Now have a dictionary with ticket... what to do next?
I’m not sure where to go next. Do you have any idea how to get all of the summaries into a NSMutableArray? I can use something other than XMLReader if that is preferred.
Try this:
The strings that you get back for your summary text may need to be trimmed, but the basic idea should work.