The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::DumpXML - Dump arbitrary data structures as XML

SYNOPSIS

 use Data::DumpXML qw(dump_xml);
 $xml = dump_xml(@list)

DESCRIPTION

This module provide a single function called dump_xml() that takes a list of something as argument and produce a string as result.

The string returned is an XML document that represents any perl data structure passed in. The following data model is used:

   data : scalar*
   scalar = undef | str | ref | alias
   ref : scalar | array | hash | glob | code
   array: scalar*
   hash: (key scalar)*

The distribution comes with an XML Schema and a DTD that more formally describe this structure.

As an example of the XML documents producted; the following call:

  $a = bless [1,2], "Foo";
  $a->[2] = \$a;
  $b = $a;
  dump_xml($a, $b);

will produce:

  <?xml version="1.0" encoding="US-ASCII"?>
  <data xmlns="http://www.cpan.org/modules/by-authors/Gisle_Aas/Data-DumpXML-1.02.xsd">
   <ref id="r1">
    <array class="Foo" id="r2">
     <str>1</str>
     <str>2</str>
     <ref>
      <alias ref="r1"/></ref></array></ref>
   <ref>
    <alias ref="r2"/></ref></data>

If dump_xml() is called in void context, then the dump will be printed on STDERR instead of being returned. For compatibility with Data::Dump there is also an alias for dump_xml() simply called dump().

You can set the variable $Data::DumpXML::INDENT to control indenting before calling dump_xml(). To suppress indenting set it as "".

The Data::DumpXML::Parser is a class that can restore datastructures dumped by dump_xml().

BUGS

Class names with 8-bit characters will be dumped as Latin-1, but converted to UTF-8 when restored by the Data::DumpXML::Parser.

The content of globs and subroutines are not dumped. They are restored as the strings; "** glob **" and "** code **".

LVALUE and IO objects are not dumped at all. They will simply disappear from the restored data structure.

SEE ALSO

Data::DumpXML::Parser, XML::Parser, XML::Dumper, Data::Dump

AUTHORS

The Data::DumpXML module is written by Gisle Aas <gisle@aas.no>, based on Data::Dump.

The Data::Dump module was written by Gisle Aas, based on Data::Dumper by Gurusamy Sarathy <gsar@umich.edu>.

 Copyright 1998-2001 Gisle Aas.
 Copyright 1996-1998 Gurusamy Sarathy.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.