[Curitiba-pm] XML em Perl
Andre Carneiro
andregarciacarneiro at gmail.com
Mon Oct 29 10:33:37 PDT 2012
Cuidado com o XML::Simple!!! Ele 'morde'... memória! Bastante memória! A
versão 'crua' dele gasta memória proporcionalmente ao tamanho do XML, ou
seja, quanto maior o XML, mais memória você gastará!
Se puder, codifique utilizando parsers que implementam SAX/SAX2 em
produção. Eles trabalham com 'eventos'. Para simplificar, não mantém o XML
todo na memória, como uma implementação 'crua' via XML::Simple. O próprio
XML::Simple tem suporte a SAX(Embora eu nunca tenha usado...). Então, RTFM
my friend!
Cheers!
On Mon, Oct 29, 2012 at 3:09 PM, Stanislaw Pusep <creaktive at gmail.com>wrote:
> Boa tarde, Guilherme!
> Seria algo assim:
>
> #!/usr/bin/env perl
> use strict;
> use warnings 'all';
> use Data::Dumper;
> use LWP::Simple;
> use XML::Simple;
>
> my $obj = XMLin(get('
> http://www.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=taxonomy&id=192')
> );
> print Dumper $obj->{Taxon}{OtherNames}{Synonym};
>
> ABS()
>
>
>
> On Mon, Oct 29, 2012 at 2:11 PM, Guilherme Rodrigues Machado <
> guilherme.lrm at gmail.com> wrote:
>
>> *Caros, boa tarde.*
>>
>> Estou utilizando os seguintes módulos:
>> - XML::SIMPLE
>> - LWP::Simple
>>
>> Para acessar o seguinte XML
>> http://www.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=taxonomy&id=192
>>
>> O retorno é +/- esse:
>>
>> $VAR1 = {
>>> 'Taxon' => {
>>> 'CreateDate' => '1995/02/27 09:24:00',
>>> 'Division' => 'Bacteria',
>>> 'TaxId' => '192',
>>> 'MitoGeneticCode' => {
>>> 'MGCId' => '0',
>>> 'MGCName' => 'Unspecified'
>>> },
>>> 'OtherNames' => {
>>> 'Includes' => 'bacterium
>>> ASAZOES-148',
>>> 'Name' => [
>>> {
>>> 'DispName' =>
>>> 'Roseomonas fauriae Rihs et al. 1998',
>>> 'ClassCDE' =>
>>> 'authority'
>>> },
>>> {
>>> 'DispName' =>
>>> 'strain sp. 7',
>>> 'ClassCDE' => 'type
>>> material'
>>> }
>>> ],
>>> 'Synonym' => [
>>> 'Roseomonas
>>> fauriae',
>>> 'Azospirillum
>>> brasiliense',
>>> 'Spirillum
>>> lipoferum'
>>> ]
>>> },
>>> 'LineageEx' => {
>>> 'Taxon' => [
>>> {
>>> 'TaxId' => '131567',
>>> 'Rank' => 'no rank',
>>> 'ScientificName' =>
>>> 'cellular organisms'
>>> },
>>> {
>>> 'TaxId' => '191',
>>> 'Rank' => 'genus',
>>> 'ScientificName' =>
>>> 'Azospirillum'
>>> }
>>> ]
>>> },
>>> 'Lineage' => 'cellular organisms; Bacteria;
>>> Proteobacteria; Alphaproteobacteria; Rhodospirillales; Rhodospirillaceae;
>>> Azospirillum',
>>> 'Rank' => 'species',
>>> 'GeneticCode' => {
>>> 'GCName' => 'Bacterial, Archaeal
>>> and Plant Plastid',
>>> 'GCId' => '11'
>>> },
>>> 'PubDate' => '1993/04/26 01:00:00',
>>> 'ScientificName' => 'Azospirillum brasilense',
>>> 'UpdateDate' => '2012/10/24 17:17:04',
>>> 'ParentTaxId' => '191'
>>> }
>>> };
>>>
>>
>>
>> Saberia dizer como eu acesso os 3 conteúdos do vetor 'SYNONYM' ?
>>
>> Muito obrigado.
>>
>> Grande abraço,
>> Guilherme Machado
>> UFPR - Mestrando em Bioinformática
>>
>> _______________________________________________
>> Curitiba-pm mailing list
>> Curitiba-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/curitiba-pm
>>
>>
>
> _______________________________________________
> Curitiba-pm mailing list
> Curitiba-pm at pm.org
> http://mail.pm.org/mailman/listinfo/curitiba-pm
>
>
--
André Garcia Carneiro
Software Engineer
(11)982907780
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/curitiba-pm/attachments/20121029/6809e00f/attachment.html>
More information about the Curitiba-pm
mailing list