Jump to content

XML parsing with bash script?

Recommended Posts

Hi all,


It appears pretty much all useful data that I want to interact with these days stores or presents its info with XML. Unfortunately, my programming knowledge really only extends to writing shell scripts (with a little AppleScript for good measure), which, as far as I can tell, can't  parse XML very nicely. What do you reckon my best option is?


  • Persevere with using clunky and tedious string manipulations (awk, sed, etc.) to extract what I want from the XML structure. Not very appealing, but I've got away with it so far.
  • There are 3rd-party xml libraries for bash (eg. xmllint), but I'm wondering if they might be more trouble than they're worth for a simple Alfred workflow.
  • Find a free php or python script that I can simply call from bash and have it return the xml values for populating into a bash array. Can anyone suggest such a thing?
  • Just bite the bullet and start learning a "proper" programming language. And if so, what? (Python? Ruby?)

I'd be interested in your thoughts.



Link to comment

Thanks Pedro. That module has to be called from a python script, right? I'm after something that is a complete python (or other) that I can call from a shell script. I realise what I'm asking is a bit unreasonable. That's why I was wondering if anyone else had some experience handling XML data with bash shell scripts.



Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...