MicroXML in Perl

Hi,

After having released the CPAN module XML::Struct for simplified XML processing, I realized that I have chosen the same data model as MicroXML:

https://metacpan.org/module/XML::Struct#DESCRIPTION

Perl's core data types array and hash directly fit to JSON data types array and object. I have just released a new version (0.15) of XML::Struct to explicitly mention MicroXML and to also conform to the data model for empty XML elements (I omitted the children array for empty elements).

Internally XML::Struct uses libxml for parsing. To disable support of namespaces, set option ns to 'disallow'. Take this little perl script to convert an XML document to a MicroXML data structure, expressed in JSON:

#!/usr/bin/perl
use XML::Struct qw(readXML);
use JSON;  
my $file = @ARGV ? shift : \*STDIN;
my $xml = readXML( $file, ns => 'disallow');
print JSON->new->utf8->pretty->encode($xml);

Bug reports and feature requests are welcome at https://github.com/nichtich/XML-Struct/issues

Jakob

P.S.: To quickly install XML::Struct from CPAN:

$ curl -L http://cpanmin.us | perl - --sudo App::cpanminus
$ sudo cpanm XML::Struct

--
Jakob Voß
Verbundzentrale des GBV (VZG)
Abteilung Digitale Bibliothek
Platz der Göttinger Sieben 1
37073 Göttingen
Telefon: (49)551 39-10242
Internet: www.gbv.de

Received on Monday, 23 September 2013 10:52:21 UTC