Skip to content

Instantly share code, notes, and snippets.

@spuder
Created April 27, 2013 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spuder/5473927 to your computer and use it in GitHub Desktop.
Save spuder/5473927 to your computer and use it in GitHub Desktop.
Why wont Alfred accept this xml?
import json
import urllib2
url="http://data.mtgox.com/api/2/BTCUSD/money/ticker"
jsonURL=urllib2.urlopen(url)
jsonObject=json.load(jsonURL)
currentValue = jsonObject['data']['high']['display']
# for some reason arg="+currentValue" doesn't work, but ..<subtitle>"+currentValue+"</subtitle> does
print ("<items><item uid='currentPrice' arg='+currentPrice+' valid='yes'><title>MtGox Current Price</title><subtitle>"+ currentValue +"</subtitle><icon>MtGox.png</icon></item></items>" ).encode('ascii', 'xmlcharrefreplace')
# if I change arg='+currentPrice+' to arg='42' then the workflow works perfectly.
@spuder
Copy link
Author

spuder commented Apr 27, 2013

Fixed. Thanks to the comment on this forum.
arg='+currentPrice+' should be arg='"+currentPrice+"'

http://www.alfredforum.com/topic/2232-workflow-xml-does-not-accept-arg/#entry12531

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment