T
Tim O'Donovan
Hi,
I'm trying to create a data structure that will (eventually) make it
easier to create a series of slightly different XML documents. The
structure will effectively hold a template.
Here's a section of code I am stuck on:
#!/usr/bin/perl -w
use strict;
use Data:umper;
my %xmldoc = (
doc1 => {
customer => [{name => 'count', format => 'int'},
{name => 'unit', format => 'text'},
],
order => [{name => 'expected', format => 'date'},
],
},
#etc
);
The problem I am having is determining how many keys are present in:
$xmldoc{doc1}
and how many elements are present in:
$xmldoc{doc1}{customer}
and so on.
I was then planning on looping through each section and using the data
to contruct the XML.
For reference, here is the dumped output of %xmldoc:
$VAR1 = 'doc1';
$VAR2 = {
'customer' => [
{
'format' => 'int',
'name' => 'count'
},
{
'format' => 'text',
'name' => 'unit'
}
],
'order' => [
{
'format' => 'date',
'name' => 'expected'
}
]
};
Any advice would be greatly appreciated.
Thanks.
Kind regards,
Tim O'Donovan
I'm trying to create a data structure that will (eventually) make it
easier to create a series of slightly different XML documents. The
structure will effectively hold a template.
Here's a section of code I am stuck on:
#!/usr/bin/perl -w
use strict;
use Data:umper;
my %xmldoc = (
doc1 => {
customer => [{name => 'count', format => 'int'},
{name => 'unit', format => 'text'},
],
order => [{name => 'expected', format => 'date'},
],
},
#etc
);
The problem I am having is determining how many keys are present in:
$xmldoc{doc1}
and how many elements are present in:
$xmldoc{doc1}{customer}
and so on.
I was then planning on looping through each section and using the data
to contruct the XML.
For reference, here is the dumped output of %xmldoc:
$VAR1 = 'doc1';
$VAR2 = {
'customer' => [
{
'format' => 'int',
'name' => 'count'
},
{
'format' => 'text',
'name' => 'unit'
}
],
'order' => [
{
'format' => 'date',
'name' => 'expected'
}
]
};
Any advice would be greatly appreciated.
Thanks.
Kind regards,
Tim O'Donovan