I found this thread , which has an example of parsing an XML file using the XML tools available through System Events. It seems pretty confusing to me though.
There is also this (free) package to add scripts for parsing / writing XML. Do not look at him, but he can be neat.
Personally, I would save my script as a script package, and then I would make a little php / Ruby / perl / python / whatever script to parse the XML (since I'm just more comfortable with this) bundled. Then I will use AppleScript and then pass the XML to the script parser from cURL.
AppleScript:
set scriptPath to POSIX path of (path to me as alias) & "Contents/Resources/parse_xml.rb" set fooValue to do shell script "curl http://foo/test.xml 2> /dev/null | ruby " & quoted form of scriptPath
parse_xml.rb could be something like this (using Ruby as an example):
require "rexml/document"
(Ruby and the REXML package should be easily accessible on any Mac, so it should work anywhere ... I suppose)
The point when the script is executed will load the XML file using cURL, pass it to the Ruby script, and at the end of << 22> the value of "bar" will be set in AppleScript.
Of course, if XML is more complex, you will need more scripting or take another look at other parameters.
There are probably even more ways to do this (for example, you could just do some string manipulation instead of completely parsing the XML, but it's a little fragile, of course), but I will stop here :)
source share