Skip to content

Instantly share code, notes, and snippets.

@moxuse
Created December 11, 2012 05:14
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 moxuse/4256067 to your computer and use it in GitHub Desktop.
Save moxuse/4256067 to your computer and use it in GitHub Desktop.
Parse cosm.com's XML feed
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