GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MKDOC::XML::DUMPER (3)

.ds Aq ’

NAME

MKDoc::XML::Dumper - Same as Data::Dumper, but with XML

CONTENTS

SYNOPSIS



  use MKDoc::XML::Dumper;
  use Test::More no_plan;
 
  my $stuff  = [ qw /foo bar baz/, [], { hello => world, yo => \\boo } ];
  my $xml    = MKDoc::XML::Dumper->perl2xml ($stuff);
  my $stuff2 = MKDoc::XML::Dumper->xml2perl ($xml);
  is_deeply ($stuff, $stuff2); # prints ok



SUMMARY

MKDoc::XML::Dumper provides functionality equivalent to Data::Dumper except that rather than serializing structures into a Perl string, it serializes them into a generic XML file format.

Of course since XML cannot be evaled, it also provides a mechanism for undumping the xml back into a perl structure.

MKDoc::XML::Dumper supports scalar references, hash references, array references, reference references, and litterals. It also supports circular structures and back references to avoid creating unwanted extra copies of the same object.

That’s all there is to it!

API

my CW$xml = MKDoc::XML::Dumper->perl2xml ($perl);

Turns $perl into an XML string. For instance:



  my $perl = [ qw /foo bar baz/, { adam => apple, bruno => berry, chris => cherry } ];
  print MKDoc::XML::Dumper->perl2xml ($perl);



Will print something like:



  <array id="135338912">
    <item key="0">
      <litteral>foo</litteral>
    </item>
    <item key="1">
      <litteral>bar</litteral>
    </item>
    <item key="2">
      <litteral>baz</litteral>
    </item>
    <item key="3">
      <hash id="135338708">
        <item key="bruno">
          <litteral>berry</litteral>
        </item>
        <item key="adam">
          <litteral>apple</litteral>
        </item>
        <item key="chris">
          <litteral>cherry</litteral>
        </item>
      </hash>
    </item>
  </array>



As you can see, every object has an id. This allows for backreferencing, so:



  my $perl = undef;
  $perl    = \$perl;
  print MKDoc::XML::Dumper->perl2xml ($perl);



Prints something like:



  <ref id="135338888">
    <backref id="135338888" />
  </ref>



For the curious, these identifiers are computed using some perl black magic:



  my $id = 0 + $reference;



my CW$perl = MKDoc::XML::Dumper->perl2xml ($xml);

Does the exact reverse operation as xml2perl().

AUTHOR

Copyright 2003 - MKDoc Holdings Ltd.

Author: Jean-Michel Hiver

This module is free software and is distributed under the same license as Perl itself. Use it at your own risk.

SEE ALSO

MKDoc::XML::Decode MKDoc::XML::Encode
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MKDOC::XML::DUMPER (3) 2004-10-06

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.