File: ex11.5.pl

package info (click to toggle)
libxml-dt-perl 0.69-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid
  • size: 388 kB
  • sloc: perl: 1,432; xml: 438; makefile: 16
file content (49 lines) | stat: -rw-r--r-- 1,471 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#######################################################
#I am using XML::DT as below (the require is for selective module loading):
#######################################################
#
#require XML::DT; XML::DT->import ();
# Yes !!!

use strict;

use Data::Dumper;
use XML::DT;

my @order=qw(volume issue doi author f_page l_page artid epub ppub type);

my $M;

my %handler = (
   '-default'   => sub {$c},
   'article' => sub {
#           $v{issue} = $dtattributes[1]->{number};
#           $v{volume} = $dtattributes[2]->{number};
           $v{issue}  = father("number");
           $v{volume} = gfather("number");

           $M .= join(" :\t", @v{(@order)}) . "\n";
    },
 );

 dt ("ex11.5.xml", %handler);
 print  $M;

__END__

<main>
<volume number="27">
  <issue number="7">
   <article doi="10.1006/jmcc.1995.0129" artid="mc950129" f_page="1359" l_page="1367"
            type="xx" author="Juhani Knuuti, M." epub="" ppub="19950700" />
   <article doi="10.1006/jmcc.1995.0130" artid="mc950130" f_page="1369" l_page="1381"
            type="xx" author="Cross, H.R." epub="" ppub="19950700" />
  </issue>

  <issue number="8">
    <article doi="10.1006/jmcc.1995.0129" artid="mc950129" f_page="1359" l_page="1367"
            type="xx" author="Juhani Knuuti, M." epub="" ppub="19950700" />
    <article doi="10.1006/jmcc.1995.0130" artid="mc950130" f_page="1369" l_page="1381"
            type="xx" author="Cross, H.R." epub="" ppub="19950700" />
</issue>