The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Importing OPML (Outline Processor Markup Language) files Thread Tools Search this Thread Display Modes
I'm trying to figure out if I can import an OPML file directly into OminFocus - at the moment I'm failing miserably.
I have a project management application (Merlin) that exports in OPML format (amongst others) and specifically mentions OmniOutliner as a target application for this file format. Since OmniOutliner is supposed to export to OmniFocus I was hoping that there's some way of getting an OMPL file directly into OmniFocus. I would not want to buy OmniOutliner just to use it as an intermediate step between the two applications.
When I try to import into OmniFocus the import dialogu doesn't even recognise the OMPL file as a valid import option. Anyone out there manged to complete this or something similar?
David.
 
You don't need to buy OmniOutliner to use it in read-only mode, and I think that's all you should need. Omni's policy is that you can use their document applications as readers for their files without charge -- helps promote their use if you can create a document with one and send it to someone who doesn't own the app!

Download OmniOutliner from the product page, fire it up and open the .OPML file you've got. Then select all the rows, copy and try to paste into OmniFocus. You'll get a dialog box that allows you to specify how OO columns map into OF data. There are some bugs right now (in OF 1.5, at least) which I've been writing up so it isn't quite trouble-free, but you should be able to get the actions/projects without too much trouble. The bugs I know about at the moment are that dates don't seem to transfer, and the cancel button on the dialog to map columns doesn't actually cancel.
 
Works a treat! Can't see any major problems that a small amount of editing won't solve and this'll save me an awful lot of retyping on something I'll only need to do occasionally.
Thanks.
 
I just came here to find out how I can transfer OPML to OmniFocus. I have OPML that comes out of CarbonFin Outliner on my iPod Touch (a nice, basic outliner). It's awesome that Omni has allowed read-only capability in their apps. This worked well.

I'll be glad to go to OmniOutliner on iPhoneOS if it ever comes out but for now CarbonFin is very useful.
 
Quote:
Originally Posted by whpalmer4 View Post
Download OmniOutliner from the product page, fire it up and open the .OPML file you've got. Then select all the rows, copy and try to paste into OmniFocus. You'll get a dialog box that allows you to specify how OO columns map into OF data
Simply dragging one or more OPML files onto a droplet app on your desktop would avoid the need for OmniOutliner and might give an easier workflow (and more control) if it needs to be done at all regularly.

I have placed a simplified version of the droplet which I use at:

http://www.complexpoint.macmate.me/S...L_into_OF.html

It creates a date-stamped OF folder of the imported projects for each OPML file that has been dragged onto the droplet.

(This version just imports the text of each opml node, and any Omni-style _note attribute, but the applescript can easily be adapted to import any other columns/attributes which your opml may have.)

The draft code (to be saved in .app format) looks like this:

Code:
-- DROPLET TO IMPORT OPML FILES INTO OMNIFOCUS

-- Ver 0.4  Now gives warning message if XML Tools osax 
-- from http://www.latenightsw.com/freeware/XMLTools2/index.html
-- has not been copied to ~/Library/ScriptingAdditions


property pstrDialogTitle : "OPML to OmniFocus Ver 0.4"
property pstrImportFolder : "Imported from OPML"
property pEmpty : ""

-- TRY TO READ THE DROPPED FILE(S) AS OPML
-- AND TRANSLATE CONTENTS OF EACH FILE
-- TO A NEW DATE-STAMPED FOLDER OF OF PROJECTS
on open lstfDropped
	set {lstFolders, lngProjects, lngFiles} to {{}, 0, 0}
	repeat with fDropped in lstfDropped
		if IsOPML(fDropped) then
			set strFile to ReadTextFile(fDropped)
			try
				set xmlDoc to parse XML strFile
				set xmlContent to (a reference to XML contents of (last item of XML contents of xmlDoc))
				set lstActivities to XML2List(xmlContent)
				set {lngActs, oFolder} to PlaceInOF(lstActivities)
				set end of lstFolders to oFolder
				set lngProjects to lngProjects + lngActs
				set lngFiles to lngFiles + 1
			on error
				set the clipboard to "http://www.latenightsw.com/freeware/XMLTools2/index.html"
				set strError to "
This script requires installation of Late Night Software's free XML Tools osax

From:

http://www.latenightsw.com/freeware/XMLTools2/index.html

(This URL is now in your clipboard, and can be pasted to a browser)

The version of the XML Tools.osax which matches your operating system should be copied to a folder with the path: 

~/Library/ScriptingAdditions
			"
				display dialog strError buttons {"OK"} with title pstrDialogTitle
				tell application id "com.apple.finder"
					set strAddns to "ScriptingAdditions"
					set fldrLibrary to folder ((path to home folder as string) & "Library") as alias
					if not (exists folder strAddns of fldrLibrary) then
						set fldrAddns to (make new folder at fldrLibrary with properties {name:strAddns})
					else
						set fldrAddns to folder strAddns of fldrLibrary
					end if
					open fldrAddns
					activate front window
				end tell
				return
			end try
		else
			display dialog "Expected file with extension .opml" with title pstrDialogTitle
		end if
	end repeat
	ShowResult(lngProjects, lstFolders, lngFiles)
end open

-- Give feedback to user
on ShowResult(lngProjects, lstFolders, lngFiles)
	if lngProjects > 0 then
		set strMsg to ((lngProjects as text) & " projects placed in OmniFocus" & return & return & ¬
			"(" & lngFiles as text) & " opml file"
		if lngFiles > 1 then
			set strMsg to strMsg & "s imported)"
		else
			set strMsg to strMsg & " imported)"
		end if
		display dialog strMsg with title pstrDialogTitle
		tell application id "com.omnigroup.OmniFocus"
			tell front document
				set recProps to {selected view mode identifier:"project", focus:lstFolders}
				set oWin to make new document window with properties recProps at front of document windows
			end tell
			activate
		end tell
	else
		display dialog "No projects found in " & strFile with title pstrDialogTitle
	end if
end ShowResult


-- CREATE A FOLDER OF PROJECTS IMPORTED FROM OPML
on PlaceInOF(lstActivities)
	set lngActivities to length of lstActivities
	if lngActivities > 0 then
		tell application id "com.omnigroup.OmniFocus"
			tell front document
				set strName to pstrImportFolder & " " & (current date)
				set oFolder to make new folder with properties {name:strName}
				my FillOFFolder(oFolder, lstActivities)
			end tell
		end tell
		{lngActivities, oFolder}
	else
		{0, missing value}
	end if
	
end PlaceInOF

-- Transfer activities to the specified project (or parent task)
on FillOFFolder(oFolder, lstActivities)
	using terms from application "OmniFocus"
		tell oFolder
			repeat with oAct in lstActivities
				set {strName, lstChiln, strNote} to oAct
				if strNote is missing value then
					set oProj to make new project with properties {name:strName}
				else
					set oProj to make new project with properties {name:strName, note:strNote}
				end if
				if length of lstChiln > 0 then my FillOFProj(oProj, lstChiln)
			end repeat
		end tell
	end using terms from
end FillOFFolder

-- Transfer activities to the specified project (or parent task)
on FillOFProj(oProj, lstActivities)
	using terms from application "OmniFocus"
		tell oProj
			repeat with oAct in lstActivities
				set {strName, lstChiln, strNote} to oAct
				if strNote is missing value then
					set oTask to make new task with properties {name:strName}
				else
					set oTask to make new task with properties {name:strName, note:strNote}
				end if
				if length of lstChiln > 0 then
					my FillOFProj(oTask, lstChiln)
				end if
			end repeat
		end tell
	end using terms from
end FillOFProj

-- READ FROM PARSED XML TO SIMPLE APPLESCRIPT LIST WITH TITLE SUB_LIST AND NOTE
on XML2List(lstContent)
	set lstText to {}
	repeat with xmlNode in lstContent
		try
			-- GET TEXT OF NODE
			set recAttribs to (a reference to XML attributes of xmlNode)
			set lngAttribs to length of recAttribs
			if lngAttribs > 0 then
				set end of lstText to {|text| of recAttribs}
			else
				set end of lstText to {pEmpty}
			end if
			
			-- GET ANY CHILDREN OF NODE
			set refNewNode to (a reference to the last item of lstText)
			set lstChildren to (a reference to XML contents of xmlNode)
			if length of lstChildren > 0 then
				set end of refNewNode to XML2List(lstChildren)
			else
				set end of refNewNode to {}
			end if
			
			-- GET ANY OMNI-STYLE _note OF NODE
			if lngAttribs > 1 then
				set strNote to pEmpty
				set strNote to _note of recAttribs
				if length of strNote > 0 then
					set end of refNewNode to strNote
				else
					set end of refNewNode to pEmpty
				end if
			else
				set end of refNewNode to pEmpty
			end if
		end try
	end repeat
	lstText
end XML2List


on ReadTextFile(fFile)
	open for access fFile
	try
		set strContents to (read fFile)
	on error
		set strContents to ""
	end try
	close access fFile
	return strContents
end ReadTextFile

-- Check that the file has an .opml extension
on IsOPML(fDropped)
	set strFileName to fDropped as string
	set {strDelim, text item delimiters} to {text item delimiters, "."}
	
	set lstParts to text items of strFileName
	set lngParts to length of lstParts
	if lngParts < 2 then
		set blnIsOPML to false
	else
		set strSuffix to (item lngParts of lstParts)
		ignoring case
			set blnIsOPML to (strSuffix is "opml")
		end ignoring
	end if
	set text item delimiters to strDelim
	blnIsOPML
end IsOPML

Last edited by RobTrew; 2012-10-01 at 07:23 AM.. Reason: Ver 0.3 allows for several opml files dropped at once
 
I have updated the OPML2OF.app file at http://www.complexpoint.macmate.me/Site/Import_OPML_into_OF.html so that it now warns the user if the free XML Tools osax from Late Night Software (which this script requires) has not yet been copied to ~/Library/ScriptingAdditions.

Rob.

--

Last edited by RobTrew; 2012-07-17 at 07:59 PM..
 
Hi,
I've installed the XML Tools.osax and I downloaded the OPML2OF.app. But when I dorp an OPML file on the App I always get the error message that I have to install the XML Tools. Any solutions?

I'm on 10.6.6
 
Quote:
Originally Posted by Ilajn View Post
I've installed the XML Tools.osax
What happens if you run this script:

Code:
on run
	display dialog XML comment as string
end run
or run the following line in a Terminal.app window:

Code:
ls ~/Library/ScriptingAdditions
?

Last edited by RobTrew; 2011-02-19 at 12:40 PM..
 
With the goal of getting my brainstormed nodes out of MindNode Pro into OmniFocus, I happened on your post about your applet, installed it along with XML Tools component and HOCUS POCUS, the OPML file exported from MindNode Pro was imported flawlessly into OmniFocus. Thanks for your work! It's very much appreciated!
 
Quote:
Originally Posted by RobTrew View Post
What happens if you run this script:

Code:
on run
	display dialog XML comment as string
end run
A window pops up saying "XML comment".

Quote:

or run the following line in a Terminal.app window:

Code:
ls ~/Library/ScriptingAdditions
?
The Terminal.app puts out:
"XML Tools.osax"
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Suggestion: Have OF Import OPML files as a new Project gattaca OmniFocus 1 for Mac 5 2013-01-29 09:17 PM
view options for OPML files twelfth OmniOutliner 3 for Mac 4 2013-01-28 10:14 PM
Import OPML files into Omnifocus ?? alexlot OmniFocus for iPad 0 2012-01-02 03:43 AM
Importing an MS outline for auto-diagramming? zeeebus OmniGraffle General 2 2009-06-28 11:21 AM


All times are GMT -8. The time now is 11:28 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.