XML::EasySQL::XMLobj 1.2 review

Download
by rbytes.net on

XML::EasySQL::XMLobj is a Fork of Robert Hanson's killer XML::EasyOBJ module, which offers Easy XML object navigation. SYNOPS

License: Perl Artistic License
File size: 11K
Developer: Robert Hanson
0 stars award from rbytes.net

XML::EasySQL::XMLobj is a Fork of Robert Hanson's killer XML::EasyOBJ module, which offers Easy XML object navigation.

SYNOPSIS

XML::EasySQL::XMLobj is a fork of Robert Hanson's XML::EasyOBJ module. The goal of the fork was to simplify inheritance issues. However, easy inheritance comes at a cost: class method names can no longer be dynamically renamed. If inheritance isn't needed and you desire the dynamic method renaming feature, I suggest you download Hanson's original XML::EasyOBJ module from CPAN.

NOTE: The rest of the documentation for this module was written by Robert Hanson
-Curtis Lee Fulton

# open exisiting file
my $doc = new XML::EasySQL::XMLobj({type => 'file', param => 'my_xml_document.xml'});

# create object from XML string
my $doc = new XML::EasySQL::XMLobj({type => 'string', -param => $xml_source});

# create new file
my $doc = new XML::EasySQL::XMLobj({type => 'new', param => 'root_tag'});

# read from document
my $text = $doc->root->some_element($index)->getString;
my $attr = $doc->root->some_element($index)->getAttr('foo');
my $element = $doc->root->some_element($index);
my @elements = $doc->root->some_element;

# first "some_element" element
my $elements = $doc->root->some_element;
# list of "some_element" elements
my @elements = $doc->root->some_element;

# write to document
$doc->root->an_element->setString('some string')
$doc->root->an_element->addString('some string')
$doc->root->an_element->setAttr('attrname', 'val')
$doc->root->an_element->setAttr('attr1' => 'val', 'attr2' => 'val2')

# access elements with non-name chars and the underlying DOM
my $element = $doc->root->getElement('foo-bar')->getElement('bar-none');
my $dom = $doc->root->foobar->getDomObj;

# get elements without specifying the element name
my @elements = $doc->root->getElement();
my $sixth_element = $doc->root->getElement('', 5);

# remove elements/attrs
$doc->root->remElement('tagname', $index);
$doc->root->tag_name->remAttr($attr);

I wrote XML::EasyOBJ a couple of years ago because it seemed to me that the DOM wasn't very "perlish" and the DOM is difficult for us mere mortals that don't use it on a regular basis. As I only need to process XML on an occasionally I wanted an easy way to do what I needed to do without having to refer back to DOM documentation each time.

A quick fact list about XML::EasySQL::XMLobj:

* Runs on top of XML::DOM
* Allows access to the DOM as needed
* Simple routines to reading and writing elements/attributes

Requirements:
Perl
XML::DOM

XML::EasySQL::XMLobj 1.2 keywords