Tree::Persist::File::XML - A handler for Tree persistence
See "SYNOPSIS" in Tree::Persist or scripts/xml.demo.pl for sample code.
This module is a plugin for Tree::Persist to store a Tree to an XML file.
This module uses double-quotes around the values of tag attributes.
Parameters are used in the call to "connect({%opts})" in Tree::Persist or "create_datastore({%opts})" in Tree::Persist.
In addition to any parameters required by its parent Tree::Persist::File, the following parameters are used by connect() or create_datastore():
connect()
create_datastore()
class (optional)
This is the name of the deflator/inflator class.
The class parameter takes precedence over the type parameter.
class
type
If class is not provided, type is used, and defaults to 'File'. Then class is determined using:
$class = $type eq 'File' ? 'Tree::Persist::File::XML' : 'Tree::Persist::DB::SelfReferential';
See t/*.t for sample code.
Tree::Persist::File::XML is a sub-class of Tree::Persist::File, and inherits all its methods.
The XML used is very simple. Each element is called "node". The node contains two attributes - "class", which represents the Tree class to build this node for, and "value", which is the serialized value contained in the node (as retrieved by the value() method.) Parent-child relationships are represented by the parent containing the child.
value()
NOTE: This plugin will currently only handle values that are strings or have a stringification method.
The 5 build-in XML character entities (within the value of the node) are encoded using this map:
my(%encode) = ('<' => '<', '>' => '>', '&' => '&', "'" => ''', '"' => '"');
They are decoded when XML::Parser reads the value back in.
See http://www.w3.org/standards/xml/core for details.
See also t/*.t for sample code.
Please see the relevant section of Tree::Persist.
Rob Kinyon <rob.kinyon@iinteractive.com>
Stevan Little <stevan.little@iinteractive.com>
Thanks to Infinity Interactive for generously donating our time.
Co-maintenance since V 1.01 is by Ron Savage <rsavage@cpan.org>. Uses of 'I' in previous versions is not me, but will be hereafter.
Copyright 2004, 2005 by Infinity Interactive, Inc.
http://www.iinteractive.com
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Tree::Persist, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tree::Persist
CPAN shell
perl -MCPAN -e shell install Tree::Persist
For more information on module installation, please visit the detailed CPAN module installation guide.