Parsing an RSS Feed

I have an RSS feed and I was wondering if there is a quick way to list all items that appear between certain XML tags without having to do some back breaking text delimiter stuff.

For example - I want to put all the content that appears between these two title tags Blah. So if there were six title my list would be something like this:

{“blah1”, “blah2”, “blah3”, “blah4”, “blah5”, “blah6”}

Does AppleScript employ a wildcard? Thanks for any help.

On Mac OS X 10.4 or later, you can parse a XML file with System Events…

System Events for the win!

—> you rocketh mosteth my friend!

Here’s a linky to how to for those looking for similar help:

http://bbs.applescript.net/viewtopic.php?pid=67105

Try something like this:

script RSSParser
	property tempFile : ""
	
	on downloadFeed(feedURL)
		-- Set script-level property; This is the file read by the other handlers
		set tempFile to POSIX path of ((path to temporary items folder as Unicode text) & "as_rss_parser.xml")
		
		do shell script "/usr/bin/curl --silent --show-error --output " & quoted form of result & " " & quoted form of feedURL
		return true
	end downloadFeed
	
	on fetchItemTitles()
		tell application "System Events"
			tell XML element "channel" of XML element "rss" of XML file tempFile
				set titleList to {}
				XML elements whose name is "item"
				
				repeat with thisItem in result
					set end of titleList to value of XML element "title" of thisItem
				end repeat
			end tell
		end tell
		return titleList
	end fetchItemTitles
end script

tell RSSParser
	downloadFeed("http://bbs.applescript.net/extern.php?action=active&type=RSS")
	fetchItemTitles()
end tell

You can simplify that handler a bit:

	on fetchItemTitles()
		tell application "System Events"
			return value of XML element "title" of (XML elements whose name is "item") ¬
				of XML element "channel" of XML element "rss" of XML file tempFile
		end tell
	end fetchItemTitles

Also check out ParserTools.

HTH

Thanks hhas. :cool: