purpose 1
Purpose 2
purpose 3
##
1. Purpose and rationale
purpose 1
Purpose 2
purpose 3
purpose list 1
list2
2. Some other heading
content 1
content 2
####
my $dom = XML::LibXML->new->parse_file($file);
my $study_str = 'Purpose and rationale|Study purpose|Study rationale'
for my $search ('/root/part/sect/header') {
my $nodeset = $dom->find($search);
foreach my $node($nodeset -> get_nodelist)
{
$node -> string_value;
if ($node =~ m/$study_str/i)
{
my $protocol = $node;
print $protocol,"\n";
#go to the next sibling
while ($node -> { Node }) {
if ($node -> { Node } -> getNextSibling ) {
$node -> { Node } = $node -> getNextSibling;
return $node -> { Node };
}
}
}
}
}