For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2004 > xml parsing









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author xml parsing
E.Horn

2004-10-28, 8:56 am

this gives me a DTD as output.
My problem is I want to parse this output!
But how can ich give it to the second code that this parses the result
of (sub_daten_einlesen)
I hope someone understands my question ;-)

#!/usr/bin/perl -w
use LWP::Simple;

sub daten_einlesen
{
print "geben Sie ein gtpprotein ein\n";
my $eingabe =<STDIN>;

my
$url='http://eutils.ncbi.nlm.nih.gov/entrez/eutils/egquery.fcgi?term=';
# print $url;
# print"\n";
$newurl= $url.$eingabe;
# print $newurl;
return $newurl;


}



$url1 =daten_einlesen();
$doc = get $url1;
print $doc;

#!/xprog/bin/perl

# use module
use XML::Simple;
use Data::Dumper;

# create object
$xml = new XML::Simple;

# read XML file
$data = $xml->XMLin("which path???");

# print output
print Dumper($data);





Philipp Traeder

2004-10-29, 8:55 am

On Thursday 28 October 2004 10:56, E.Horn wrote:

Good morning,

> this gives me a DTD as output.


DTD?
As in the kind of document that describes XML files?
If yes, an XML Parser might be the wrong tool for parsing this kind of file.
Could you give us an example?

> My problem is I want to parse this output!
> But how can ich give it to the second code that this parses the result
> of (sub_daten_einlesen)
> I hope someone understands my question ;-)


[..snipped some code...]
>
>
> $url1 =daten_einlesen();
> $doc = get $url1;
> print $doc;


>
> #!/xprog/bin/perl
>
> # use module
> use XML::Simple;
> use Data::Dumper;
>
> # create object
> $xml = new XML::Simple;
>
> # read XML file
> $data = $xml->XMLin("which path???");


If the output you want to parse is stored in $doc, you should be able to pass
it directly to XML::Simple:

my $data = $xml->XMLin($doc);

HTH,

Philipp
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com