DBD::XMLSimple - Access XML data via the DBI interface
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):'); $dbh->func('person', 'XML', "$Bin/../data/person.xml", 'xmlsimple_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>email@example.com</email> </row> <row id="2"> <name>A N Other</name> <email>firstname.lastname@example.org</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>email@example.com</email> <email>firstname.lastname@example.org</email> </row> </table> $sth = $dbh->prepare("Select email FROM person"); $sth->execute(); $sth->dump_results(); Gives the output "email@example.com,firstname.lastname@example.org"
No routines in this module should be called directly by the application.
<njh at bandsman.co.uk>
DBD::AnyData, which was also used as a template for this module.
You can find documentation for this module with the perldoc command.
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
Copyright 2016-2017 Nigel Horne.
This program is released under the following licence: GPL