![]() | Ned Batchelder : Blog | Code | Text | Site Prettying XML in Komodo » Home : Blog : December 2009 |
Prettying XML in KomodoWednesday 2 December 2009 I use ActiveState Komodo as my editor these days, and have for a while. It's got just the right feature set for me, including scriptability in Python. I haven't dug into the scripting much, but one constant need finally drove me to learn more about it. At work, we often deal with chunks of data sent from servers in either XML or JSON formats, and that data is rarely indented for readability. So I often need to pretty up a file so that I can see what's going on. Here's a Komodo Python script to prettify XML, either the current selection, or the entire document: import xml.dom.minidom as md Unfortunately, the Komodo scripting docs are not great: they are fairly terse, with not much introductory material to help you find your way around. And the Python bindings are step-children: you have to read about JavaScript, then translate to Python in your head. But you can call into the extensive Python standard library to get done what you need done, so the power is there. I also made a JSON prettifier by using this filter function in the above code: def pretty_json(j):
tagged:
ides» react | |
Comments
Add a comment: