• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSRange
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSRange


  • Subject: Re: NSRange
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 14 May 2008 21:22:34 -0700


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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSRange (From: "Mr. Gecko" <email@hidden>)

  • Prev by Date: Re: Assertion failure in -[NSNextStepFrame lockFocus]
  • Next by Date: window controller's [self window] not working
  • Previous by thread: Re: NSRange
  • Next by thread: cross-development Problems
  • Index(es):
    • Date
    • Thread