topfunky / hpple

An XML/HTML parser for Objective-C, inspired by Hpricot.
http://topfunky.com
MIT License
2.77k stars 473 forks source link

how to ignore <br /> #6

Open williamhqs opened 13 years ago

williamhqs commented 13 years ago

Dear topFunky, how should i ignore <<br />>? the html file like this: <div class="Fiche"> <p>Every Sunday, our Chef proposes a buffet high in color.<br /> <br /> A brunch <br /> <br /> Every <br /> <br /> Information/ reservations : (377) 98 06 03 60</p>

When i parse the text between<p> and</p>, what i only get is: Information/ reservations : (377) 98 06 03 60. How should i ignore <br />, thanks a lot!

My code: NSArray array4Soustitre = [xpathParser search:@"//div [@class='Fiche']/p"]; TFHppleElement ele= [array4Soustitre objectAtIndex:0]; NSLog(@"content is %@ ",[ele content]);

seaneseor commented 13 years ago

what if you stripped your string of <br /> beforehand?

I meant to link to: – stringByReplacingOccurrencesOfString:withString: http://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/stringByReplacingOccurrencesOfString:withString:

magnett commented 11 years ago

The above possible solution doesn't work.