DBD-XMLSimple

Access XML data via the DBI interface


License
Other

Documentation

DBD::XMLSimple

Access XML data via the DBI interface

VERSION

Version 0.05

SYNOPSIS

Reads XML and makes it available via DBI.

Sadly DBD::AnyData doesn't work with the latest DBI and DBD::AnyData2 isn't out yet, so I am writing this pending the publication of DBD::AnyData2

DBD-XMLSimple doesn't yet expect to support complex XML data, so that's why it's not called DBD-XML.

use FindBin qw($Bin);
use DBI;

my $dbh = DBI->connect('dbi:XMLSimple(RaiseError => 1):');

# To be replaced with xmls_import once the driver has been registered
$dbh->func('person', 'XML', "$Bin/../data/person.xml", 'x_import');

my $sth = $dbh->prepare("SELECT * FROM person");

Input data will be something like this:

<?xml version="1.0" encoding="US-ASCII"?>
<table>
    <row id="1">
        <name>Nigel Horne</name>
        <email>njh@bandsman.co.uk</email>
    </row>
    <row id="2">
        <name>A N Other</name>
        <email>nobody@example.com</email>
    </row>
</table>

If a leaf appears twice it will be concatenated

<?xml version="1.0" encoding="US-ASCII"?>
<table>
    <row id="1">
        <name>Nigel Horne</name>
        <email>njh@bandsman.co.uk</email>
        <email>nhorne@pause.org</email>
    </row>
</table>

$sth = $dbh->prepare("Select email FROM person");
$sth->execute();
$sth->dump_results();

Gives the output "njh@bandsman.co.uk,nhorne@pause.org"

SUBROUTINES/METHODS

driver

No routines in this module should be called directly by the application.

AUTHOR

Nigel Horne, <njh at bandsman.co.uk>

BUGS

Change x_import to xmls_import once it's been registered

SEE ALSO

DBD::AnyData, which was also used as a template for this module.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc DBD::XMLSimple

You can also look for information at:

LICENCE AND COPYRIGHT

Copyright 2016 Nigel Horne.

This program is released under the following licence: GPL