DBIx-XML-DataLoader
view release on metacpan or search on metacpan
DataLoader/XMLWriter.pm view on Meta::CPAN
if($rootcnt > 0){
my $xmldoc=\%doc;
my %predoc;
$predoc{MultiQueryDoc}->{content}="\n".$parser->XMLout($xmldoc);
$xmldoc=\%predoc;
$thexml=$parser->XMLout($xmldoc,
xmldecl=>qq[<?xml version='1.0' standalone='yes'?>\n
<!-- document created using XMLWriter $VERSION at $date -->]);
}
return($thexml);
#############
} # end sub makexml
######################
1;
__END__
=head1 NAME
DBIx::XML::DataLoader::XMLWriter
=head1 SYNOPSIS
use DBIx::XML::DataLoader::XMLWriter;
my $doc=DBIx::XML::DataLoader::XMLWriter->makexml(\%all_data, $doc_root);
=for text or
=for man .SH "\tor"
=for man .IX Subsection "\tor"
=for html <b>or</b>
use DBIx::XML::DataLoader::XMLWriter;
my $w=DBIx::XML::DataLoader::XMLWriter->new();
my $doc=$w->makexml(\%all_data, $doc_root);
=head1 DESCRIPTION
XMLWriter is packaged as part of the DBIx::XML::DataLoader module.
XMLWriter.pm will take a referance to a data structure and
output xml based upon the contents of the referanced data.
=head1 SIMPLE EXAMPLE
The data sent to XMLWriter needs to be in the following structure.
XMLWriter expects to get hash referance to a hash that contains
a hash keyed to table names, with each table key's value is a hash
containing a data hash and keys for (parent, xpath, and node);
The data hash will contain all data for a given segment of xml.
The hash is keyed by numbers that are based on the number of iterations
of data contained in the hash. Each number key points to a array of hash which
contain the actual data, item_node, xpath, and a attribute. Only the attribute node is
optional.
=head1 SAMPLE CODE
use DBIx::XML::DataLoader::XMLWriter;
$rootnode="docroot";
%sample=(
xml_a=>(
data=>(
1=>[{
val='hello',
item_node='first',
xpath=>'./message',
attribute=>undef
},
{
val='world',
item_node='second',
xpath=>'./message',
attribute=>undef
}],
parent=> undef,
xpath=>'./welcome/message',
node=>'welcome'
);
print DBIx::XML::DataLoader::XMLWriter->makexml(\%sample, $doc_root);
=for text or
=for man or
=for html <b>or</b>
use DBIx::XML::DataLoader::XMLWriter;
my $w=DBIx::XML::DataLoader::XMLWriter->new();
$rootnode="docroot";
%sample=(
xml_a=>(
data=>(
1=>[{
val='hello',
item_node='first',
xpath=>'./message',
attribute=>undef
},
{
val='world',
item_node='second',
xpath=>'./message',
attribute=>undef
}],
( run in 0.714 second using v1.01-cache-2.11-cpan-71847e10f99 )