Saturday, March 20, 2010

Building XMLStarlet in Snow Leopard (OSX 10.6)

XMLStarlet is a command line XML toolkit. Very useful if you want to parse some data from a webpage, RSS feed of similar. XMLStarlet does not provide a binary version for Snow Leopard. They do however provide their source under the MIT licence. So your free to download, build and modify.

To get XMLStarlet up and running on Snow Leopard is nice and easy.

  1. Install Xcode with the Unix the Unix Dev Support Option (see my past post about building wget for more details on this).

  2. Go download yourself a copy of the XMLStarlet source (I am using v 1.0.1).

  3. XMLStarlet requires libxml2 and libxslt. Snow Leopard ships with both these libraries installed, however they are not in the location expected by the XMLStarlet build script so some symlinks are required. Enter the following in a terminal:
    sudo ln -s /usr/lib/libxslt.1.dylib /usr/lib/libxslt.a
    sudo ln -s /usr/lib/libexslt.dylib /usr/lib/libexslt.a
    sudo ln -s /usr/lib/libxml2.dylib /usr/lib/libxml2.a
  4. Unpack the XMLStarlet tarball by double clicking it in Finder.
    Take note of the name of the newly unpacked directory (something like xmlstarlet-1.0.1).

  5. Open a terminal and cd to where you just unpacked (by default this will be the directory below).
    cd ~/Downloads/xmlstarlet-1*
  6. Run the configure script:
  7. Run the builds
  8. Run the installer:
    sudo make install
  9. Finally, to test that the install worked correctly enter the following in a terminal:
    TA:~ troy$ xml 
    XMLStarlet Toolkit: Command line utilities for XML
    XMLStarlet is a command line toolkit to query/edit/check/transform XML documents 
    (for more information see


russurquhart1 said...

I have been having problem compiling this for os 10.4.11, have you had any luck with this? It seems to want libiconv as well.

Troy Test 1234 said...

@russur I don't have an OSX 10.4 machine to try it out on. However the library does not seem to be loaded on OSX 10.6. See below.

$ otool -L `which xml`
/usr/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.24.0)
/usr/lib/libexslt.0.dylib (compatibility version 9.0.0, current version 9.13.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)
/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.3.0)

Post a Comment