« Ubiquity | Main | Priceless »

Pretty print XML

In case you didn't know, you can pretty print XML with the xmllint command line tool that comes with libxml2, and its installed by default with Mac OS X.

Basic usage is

xmllint --format xml_file.xml

and the pretty version will be sent to standard output.

But working with XMPP and SAPO Broker, I'm always copy&pasting XML from one place to the other and it would be nice to format the XML snippet sitting in the clipboard.

This pipe does the trick quite nicely:

pbpaste | xmllint --format - | pbcopy

I wrapped this into a script, called x-xml-format-clipboard and now its just one command away from gratification.

Next step, create a version that I can place in the services menu. I need to find a way to access the selected text on the current Cocoa app. I hope thats not to hard. Making the final script a service is definitively easy, using the ThisService app.

Contacts

melo@simplicidade.org (XMPP/email)
+351 302 029 050 (voice)
melopt (Skype)

IronMan challenge

Iron Man badge Are you ready to be an Iron Man? Join the challenge and find out! (what is the meaning of this little man?)

Moosaico

Junta-te!

Recent Comments

Powered by Disqus
Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.2