PDA

View Full Version : Getting Rid of URLs While Parsing?




jpmcgrath
Jul 25, 2011, 09:13 AM
I'm parsing an XML feed that is full of HTML elements (e.g. <em></em>, etc.) but I do not want those to show up in my application as plain text. Is there a way to get rid of them?



RonC
Jul 25, 2011, 08:27 PM
I'm parsing an XML feed that is full of HTML elements (e.g. <em></em>, etc.) but I do not want those to show up in my application as plain text. Is there a way to get rid of them?

Use NSXMLParser (http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40003773) and implement the delegate methods. For every element in the XML feed, the appropriate delegate methods will be called.

dejo
Jul 26, 2011, 08:08 AM
First, I don't think you meant to say URLs in your thread title. URLs and HTML tags are very different things.

Second, you might also want to consider simply passing your HTML string through a regular expression to remove all the HTML tags. I suspect you may even find some pre-existing solutions (i.e. patterns) out there on the internet.