Serializing data from Tcl

Tcl still is in use in a number of environments like embedded devices. However, looking at Tcl code fragments reminded me of why I gave up on Tcl many years ago. I can't really recommend spending much time in Tcl.

However, if Tcl is your only choice for "primary information", then you need to translate the information from a Tcl structure into another format. Potential candidates for this are XML, JSON, or YAML. I think JSON is a little better for most simple data structures you may find in Tcl, but pick your poison.


Using XML in Tcl

I used to do quite a bit of Tcl programming back in the mid to late 1990s. I've since largely dropped it, but Tcl still is used quite a bit in specialized use cases.

To use Tcl with XML, it seems like the most popular solution is the TclXML package :

From what I can tell, it's the best / only package for XML in Tcl, although here's a 11-year old article by Steve Ball which seems to reference other approaches :


XMLWriter in Perl, PHP and Tcl

Here's some information on XMLWriter.

It looks like popular XMLWriter implementations in PHP, Perl and Tcl just wrap the C library libxml2 (or older libxml) :

For Perl, there's a CPAN XMLWriter :

For PHP, there's an old PECL library that looks like it will work with older versions (4.x) of PHP :

Subscribe to RSS - XML