Thread XML fehler (18 answers)
Opened by paidopoieo at 2006-06-14 21:35

paidopoieo
 2006-06-15 02:28
#67370 #67370
User since
2005-12-02
96 Artikel
BenutzerIn
[default_avatar]
hi,
danke fuer den tipp....
hab das auch jetzt umgeaendert, jedoch will es mir den text des idtags nicht ausgeben, will den text haben und dann einfach in einer variablen speichern ....

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
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
60
61
62
63
64
65
66
67
68
69
#!/usr/local/bin/perl -w

#use strict;
#use warnings;
use DBI;
use Net::MySQL;
use HTTP::Request::Common;
use LWP::UserAgent;
use CGI qw(header -no_debug);
use XML::Twig;

#==============================database connection================================================


#=============================end database connection==================================================


$mysql->query(qq{SELECT accession_code FROM protein});

my $record_set = $mysql->create_record_iterator;

while (my $record = $record_set->each) {
print "Accession ID: $record->[0] \n";

#For retrieving data from a url post in perl, we will use the LWP module "get" function

use LWP::Simple; #supports the "get" function

$baseurl="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/";
$eutil="esearch.fcgi?";
$parameters="db=protein&term=$record->[0]&retmode=xml";
$url=$baseurl.$eutil.$parameters;

$raw=get($url);

open(FILE, ">$record->[0]");
print FILE $raw;
close FILE;

$xml_file = $record->[0];

my $twig= XML::Twig->new(

TwigHandlers => {

"/eSearchResult/IdList/Id" => \&id_Tag

}
);


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



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

print $idTag->text(), "\n";

# Release memory of processed tree up to here
$t->purge();
}

}
\n\n

<!--EDIT|paidopoieo|1150324154-->

View full thread XML fehler