Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting data of Child Element from its Parent counterpart
    primarykey
    data
    text
    <p>im trying to parse the child data which is sub_category and show it, but will only show the relevant sub_category of the parent category. I was sucessful in parsing the data of the parent element but im having a problem on how to parse the child element.</p> <pre><code>- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { if([elementName isEqualToString:@"category"]){ dataCurrent = [dataFileHolder alloc]; } } - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { currentList = [[NSMutableString alloc] initWithString:[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; } - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if([elementName isEqualToString:@"name"]){ dataCurrent.nameOfCat = currentList; } if ([elementName isEqualToString:@"description"]){ dataCurrent.descriptionOfCat = currentList; } if ([elementName isEqualToString:@"image"]) { dataCurrent.imageLink = currentList; } if ([elementName isEqualToString:@"category"]) { [listPopulated addObject:dataCurrent]; dataCurrent = nil; currentList = nil; } } </code></pre> <p>and the XML file is like this</p> <pre><code>&lt;category&gt; &lt;name&gt;Food&lt;/name&gt; &lt;description&gt;food description&lt;/description&gt; &lt;image&gt; Link Here &lt;/image&gt; &lt;sub_cat&gt; &lt;sub_name&gt;Sub name&lt;/sub_name&gt; &lt;sub_desc&gt;sub cat description&lt;/sub_desc&gt; &lt;sub_image&gt; Link &lt;/sub_image&gt; &lt;/sub_cat&gt; &lt;sub_cat&gt; &lt;sub_name&gt;Sub name&lt;/sub_name&gt; &lt;sub_desc&gt;sub cat description&lt;/sub_desc&gt; &lt;sub_image&gt; Link &lt;/sub_image&gt; &lt;/sub_cat&gt; &lt;/category&gt; </code></pre> <p>and I been researching about the <a href="https://developer.apple.com/library/ios/documentation/cocoa/Conceptual/XMLParsing/XMLParsing.html#//apple_ref/doc/uid/10000186i" rel="nofollow noreferrer">Event Driven XML Parsing</a> and also find a gud reference from one of the threads <a href="https://stackoverflow.com/questions/17224769/xml-parse-only-certain-child-elements">xml-parse-only-certain-child-elements</a>, but at the end im still pretty confuse about the XML and parsing stuff. I might need a lamer term. And would like to know on how to do my parsing part.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload