
rantan
New User
Jun 5, 2013, 12:51 AM
Post #1 of 1
(1293 views)
|
Hello, i`am new in Perl an XML. I have writen a script witch parse a XML File and give me an output. The Problem is there are duplicate data in the XML file. Now i want first read out the Attribute from 'lst name="alfresco"' and in the next step i want parse the Attribut 'lst name="archive"'. Can anyone help? Greets Jürgen
#!/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";
<?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>
|