Sophie

Sophie

distrib > Mageia > 4 > i586 > media > core-release > by-pkgid > 5e026487d12798a8f8229cb56dab2765 > files > 7

perl-XML-DBMS-1.03-20.mga4.noarch.rpm

# note starting ver 1.03 XMLtoDBMS the #$doc->dispose; is not required as we use XML::LibXML not XML::DOM
# there is some warning message coming up "Attempt to free unreferenced scalar"
#  that I was not able to figure out so far but it must be libxml problem that must go away sooner or later.

use DBI;
use XML::XMLtoDBMS;

my $dbh = DBI->connect("dbi:ODBC:test");
my $xmlTodbms = new XML::XMLtoDBMS($dbh);

my ($xml, $doc);

$xmlTodbms->setMap('e:\cvs\xml-dbms\samples\sales.map');
$doc = $xmlTodbms->storeDocument( Source => {File => 'e:\cvs\xml-dbms\samples\sales.xml'} );
#$doc->dispose;

$doc = $xmlTodbms->retrieveDocument('Sales', [['123']]); 
print $doc->toString;
print "\n";

#select all records - if there is more then one records make sure you have PseudoRoot to create valid XML
$doc = $xmlTodbms->retrieveDocument('Sales');
print $doc->toString;
print "\n";

#let's  change output format, there is no PseudoRoot element
#running this script for second time should produce invalid XML - multiple root nodes
$xmlTodbms->setMap('e:\cvs\xml-dbms\samples\sales1.map');
$doc = $xmlTodbms->retrieveDocument('Sales');
print $doc->toString;
print "\n";

#lets test filtering with parameters and level control (moving related class node up and down the heirarchy
$xmlTodbms->setMap('e:\cvs\xml-dbms\samples\sales2.map');
$doc = $xmlTodbms->retrieveDocument('Sales', [['123']], {PartNumber=>'123'}); 
print  $doc->toString;

$xmlTodbms->destroy;
$dbh->disconnect;