Hallo,
bin total neu in Perl und in XML. Ich hab mir nun mal ein kleines Script geschrieben, welches eine XML parst und ein paar Werte ausgibt.
Das Problem ist, dass die Werte bzw. Attribute doppelt vorkommen. Ich möchte aber erstmal nur die Attribute von <lst name="alfresco"> ausgeben und im zweiten Schritt die Attribute von <lst name="archive">.
Kann mir jemand helfen?
Danke und Gruß
Jürgen
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
#!/usr/bin/perl
use XML::LibXML;
use Switch;
my $object = $ARGV[0];
my $datei = 'bla.xml';
my $mein_objekt = XML::LibXML->new();
my $Baumobjekt = $mein_objekt->parse_file($datei);
my $wurzel = $Baumobjekt->getDocumentElement;
my @knoten = $wurzel->getElementsByTagName('lst');
my @knot = $wurzel->getElementsByTagName('long');
my @objects;
my @content1;
my $i = 0;
foreach my $einzelne_Knoten (@knot)
{
$name=$einzelne_Knoten->getAttribute('name');
$content2=$einzelne_Knoten->textContent;
print "$name = $content2 \n";
$objects[$i] = $name;
$content1[$i] = $content2;
$i++;
}
print "\n$objects[5] = $content1[5]\n";
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
50
51
52
53
54
55
56
57
58
59
<?xml version="1.0" encoding="UTF-8" ?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">53649</int>
</lst>
<lst name="report">
<lst name="alfresco">
<long name="DB transaction count">136902</long>
<long name="DB acl transaction count">970</long>
<long name="Count of duplicated transactions in the index">0</long>
<long name="Count of duplicated acl transactions in the index">0</long>
<long name="Count of transactions in the index but not the DB">0</long>
<long name="Count of acl transactions in the index but not the DB">0</long>
<long name="Count of missing transactions from the Index">0</long>
<long name="Count of missing acl transactions from the Index">0</long>
<long name="Index transaction count">136902</long>
<long name="Index acl transaction count">970</long>
<long name="Index unique transaction count">136902</long>
<long name="Index unique acl transaction count">970</long>
<long name="Index leaf count">628585</long>
<long name="Count of duplicate leaves in the index">0</long>
<long name="Index aux count">628585</long>
<long name="Count of duplicate aux docs in the index">0</long>
<long name="Index error count">0</long>
<long name="Count of duplicate error docs in the index">0</long>
<long name="Index unindexed count">1812</long>
<long name="Count of duplicate unindexed docs in the index">0</long>
<long name="Last index commit time">1370343490031</long>
<str name="Last Index commit date">2013-06-04T12:58:10</str>
<long name="Last TX id before holes">138452</long>
</lst>
<lst name="archive">
<long name="DB transaction count">136902</long>
<long name="DB acl transaction count">970</long>
<long name="Count of duplicated transactions in the index">0</long>
<long name="Count of duplicated acl transactions in the index">0</long>
<long name="Count of transactions in the index but not the DB">0</long>
<long name="Count of acl transactions in the index but not the DB">0</long>
<long name="Count of missing transactions from the Index">0</long>
<long name="Count of missing acl transactions from the Index">0</long>
<long name="Index transaction count">136902</long>
<long name="Index acl transaction count">970</long>
<long name="Index unique transaction count">136902</long>
<long name="Index unique acl transaction count">970</long>
<long name="Index leaf count">1463</long>
<long name="Count of duplicate leaves in the index">0</long>
<long name="Index aux count">1463</long>
<long name="Count of duplicate aux docs in the index">0</long>
<long name="Index error count">0</long>
<long name="Count of duplicate error docs in the index">0</long>
<long name="Index unindexed count">0</long>
<long name="Count of duplicate unindexed docs in the index">0</long>
<long name="Last index commit time">1370343490031</long>
<str name="Last Index commit date">2013-06-04T12:58:10</str>
<long name="Last TX id before holes">138452</long>
</lst>
</lst>
</response>