Re: NSString Parsing
Re: NSString Parsing
- Subject: Re: NSString Parsing
- From: Chris Parker <email@hidden>
- Date: Tue, 29 Oct 2002 09:16:56 -0800
On Tuesday, October 29, 2002, at 12:32 AM, Simon Stapleton wrote:
From: Peer Allan <email@hidden>
What I want to do is extract all the text from in between a pair or
tags
(<td>...</td> for example). I know I could use a rangeOfString: call
to get
the first one, but then I have to create a new string with the
remaining
data and call rangeOfString: again to get the next and on and on
until the
whole string is parsed. I hope there is a better way to do this.
CFXMLParser would seem to be the thing you want. See the Core
Foundation XML services documentation. As long as your html is
well-formed, it should be relatively easy.
Unfortunately the odds that average HTML that you find is well-formed
is pretty close to nil, although that's getting better with the
proliferation of tools like Dreamweaver (I'm still an emacs html-mode
guy myself, but that's just me). Unless you know the page is XHTML,
CoreFoundation's XML parser isn't going to be of much help.
It strikes me that rather than creating a new string with the remaining
data, you could use NSScanner or an anchored search, moving your range
up as you go.
.chris
--
Chris Parker
Cocoa Frameworks Engineer
Apple Computer, Inc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.