Created
December 11, 2012 05:14
-
-
Save moxuse/4256067 to your computer and use it in GitHub Desktop.
Parse cosm.com's XML feed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = DOMDocument.new; | |
x.parseXML( "curl --request GET \ --header \"X-ApiKey: APIKEY_HERE\" \ http://api.cosm.com/v2/feeds/FEED_NUM.xml".unixCmdGetStdOut; ); | |
m = x.getElementsByTagName("data"); | |
m.do({arg item; | |
var child; | |
v = item.getAttribute("id"); | |
child = item.getChildNodes; | |
child.do({arg ch; | |
if ( "current_value" == ch.getTagName , { | |
ch.getText.postln; | |
}); | |
if ( "unit" == ch.getTagName , { | |
ch.getText.postln; | |
}); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment