ios - NSXML Parser find parent's child nodes -


i'm totally new xml parse, have xml structure like..

   <chapter name = "chap1">    <pages>one.html</pages>    <pages>two.html</pages>    </chapter>    chapter name = "chap2">    <pages>one.html</pages>    <pages>two.html</pages>    </chapter>    <chapter name = "chap3">    </chapter> 

i want take each chapters pages separately... i.e if chapter has pages node want yes else no. how can parse..i'm using nsxml parser

you have try this,

- (void)parser:(nsxmlparser *)parser didstartelement:(nsstring *)elementname namespaceuri:(nsstring *)namespaceuri qualifiedname:(nsstring *)qname attributes:(nsdictionary *)attributedict {      if ([elementname isequaltostring:@"chapter"])       {          chapteroneflag = yes;//use bool      } } - (void)parser:(nsxmlparser *)parser foundcharacters:(nsmutablestring *)string {         buffcontent=[buffcontent stringbyappendingstring:string]; } - (void)parser:(nsxmlparser *)parser didendelement:(nsstring *)elementname namespaceuri:(nsstring *)namespaceuri qualifiedname:(nsstring *)qname {       if (chapteroneflag == yes)       {         if ([elementname isequaltostring:@"pages"])          {              [yourarr addobject:buffcontent];         }      } } 

is code want?. here can use youarr. come separately.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -