Monday, November 08, 2010 at 12:00 AM.

river2Suite.opmlImport

on opmlImport (opmltext) {
	<<Changes
		<<12/26/09; 6:06:54 PM by DW
			<<Declare local variable -- adr.
		<<9/9/09; 10:15:17 AM by DW
			<<Rewritten to use new code for reading list support, much simpler and can deal with structured OPML, not just flat OPML. 
				<<Old code
					<<local (adrdata = river2suite.init (), xstruct)
					<<xml.compile (opmltext, @xstruct)
					<<scratchpad.xstruct = xstruct
					<<local (adropml = xml.getaddress (@xstruct, "opml"))
					<<local (adrbody = xml.getaddress (adropml, "body"), adr)
					<<for adr in adrbody
						<<if nameof (adr^) endswith "outline"
							<<try
								<<local (url = xml.getattributevalue (adr, "xmlUrl"))
								<<river2Suite.subscribeFeed (url)
							<<else
								<<adrdata^.stats.lastImportError = tryerror
								<<adrdata^.stats.whenLastImportError = clock.now ()
		<<6/22/09; 4:50:13 PM by DW
			<<Created. 
	local (adrdata = river2suite.init (), feeds, adr);
	xml.rss.getOpmlFeeds (opmltext, @feeds);
	for adr in @feeds {
		try {
			local (url = nameof (adr^));
			river2Suite.subscribeFeed (url)}
		else {
			adrdata^.stats.lastImportError = tryerror;
			adrdata^.stats.whenLastImportError = clock.now ()}}}
<<bundle //test code
	<<local (f = "Ohio:OPML Editor stuff:defaultFeeds.opml")
	<<file.writewholefile (f, op.outlinetoxml (@river2Suite.data.defaultFeeds))
	<<local (s = file.readwholefile (f))
	<<opmlImport (s)



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.