Skip navigation.
 
mlRe: NSRange
FROM : Jens Alfke
DATE : Thu May 15 06:22:34 2008

On 14 May '08, at 4:25 PM, Mr. Gecko wrote:

> <a href="example.com" title="Ttitle">text I want</a>
> so I want to get the text in the middle of points  title="Ttitle"> 
> and </a>


Trying to parse HTML by hand like this is a good way to lose your 
mind. Seriously, don't try it. Simple searching through strings 
looking for delimiters doesn't always work, due to quoting and things 
like that. The only way to do it reliably is to write a parser that 
knows the rules of HTML, and even then you have to deal with the fact 
that many, many websites are full of really broken HTML.

And you don't need to do that, when NSXML will do the parsing for you. 
Learn XPath and you can extract things like your example in one line 
of code.

> I have heard of NSRange but I can't find documentation to it in xcode.


Just open the documentation window and type "NSRange" into the search 
field.
Or find the word NSRange in an editor window and option-double-click it.
Or go here:
   file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html
#//apple_ref/doc/uid/20000018-DontLinkElementID_14

—Jens

Related mailsAuthorDate
mlNSRange Mr. Gecko May 15, 01:25
mlRe: NSRange Randall Meadows May 15, 01:33
mlRe: NSRange Mr. Gecko May 15, 01:39
mlRe: NSRange Andy Lee May 15, 01:48
mlRe: NSRange Jens Alfke May 15, 06:22