Thread xml file parsen (3 answers)
Opened by paidopoieo at 2006-06-15 20:19

paidopoieo
 2006-06-15 20:19
#67391 #67391
User since
2005-12-02
96 Artikel
BenutzerIn
[default_avatar]
hi,
hab noch ein anderes problem, versuch da ein zweites xml file zu parsen:
ich brauche von dort den Inhalt des TaxId attribut:

xml:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE eSummaryResult PUBLIC "-//NLM//DTD eSummaryResult, 11 May 2002//EN" "http://www.ncbi.nlm.nih.gov/entrez/query/DTD/eSummary_041029.dtd">
<eSummaryResult>

<DocSum>
<Id>29427659</Id>
<Item Name="Caption" Type="String">P81928</Item>
<Item Name="Title" Type="String">RPII140-upstream gene protein</Item>
<Item Name="Extra" Type="String">gi|29427659|sp|P81928|140U_DROME[29427659]</Item>
<Item Name="Gi" Type="Integer">29427659</Item>
<Item Name="CreateDate" Type="String">2003/03/28</Item>
<Item Name="UpdateDate" Type="String">2006/04/04</Item>
<Item Name="Flags" Type="Integer">0</Item>
<Item Name="TaxId" Type="Integer">7227</Item>
<Item Name="Status" Type="String">live</Item>
<Item Name="ReplacedBy" Type="String"></Item>
<Item Name="Comment" Type="String"><![CDATA[ ]]></Item>
</DocSum>


</eSummaryResult>


Codefragment:

Code: (dl )
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
 my $twig= XML::Twig->new(

TwigHandlers => {

Id => \&id_Tag

}
);


#actually parse the file
$twig->parsefile($xml_file) or die "cannot parse [$xml_file]: $!";



###########################################
sub id_Tag {
###########################################
my($t, $idTag)= @_;

my $id = $idTag->first_child('Item');
$idText = $id->{'att'}->{'TaxId'};
print "TAX_ID: ",$idText,"\n";
# Release memory of processed tree up to here
$t->purge();
}


mit der fehlermeldung:
Code: (dl )
Use of uninitialized value


sorry, komme aber echt nicht weiter....

View full thread xml file parsen