I have following XML that I want to create and populate with data through Perl script. In this XML I have some collection type of attributes i.e primarySiteCollection.
How do I dynamically populate and generate the 'primarySiteCollection' node. In this XML the primarySiteCollection contain 3 tissue sites, but there can be 1 or many.
<TumorDetails>
<personUpi>String</personUpi>
<ageAtDiagnosis>3.14159E0</ageAtDiagnosis>
<biopsyPathologyReportSummary>String</biopsyPathologyReportSummary>
<primarySiteCollection>
<tissueSite>
<description>String1</description>
<name>String1</name>
</tissueSite>
<tissueSite>
<description>String2</description>
<name>String2</name>
</tissueSite>
<tissueSite>
<description>String3</description>
<name>String3</name>
</tissueSite>
</primarySiteCollection>
</TumorDetails>
This is my Perl script. I wanted to generate the node dynamically containing collection type of attributes.
use strict;
use warnings;
use XML::Compile::Schema;
my $node = {
personUpi => 'String',
ageAtDiagnosis => '3.14159E0',
biopsyPathologyReportSummary => 'String',
primarySiteCollection => {
tissueSite => {
description => 'String',
name => 'String',
},
},
};
my $schema = XML::Compile::Schema->new('sample.xsd');
my $writer = $schema->compile(WRITER => 'TumorDetails');
my $doc = XML::LibXML::Document->new(q(1.0), q(UTF-8));
print $writer->($doc, $node)->toString;