<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV></DIV>
<DIV> Opa, valeu pela dica... Eu sempre uso o strict e o -w... Neste exemplo eu tirei para ir tentando na força bruta, hehehehe...</DIV>
<DIV> Bom, o Data::Dumper somente me mostra o conteúdo correto ? Ou eu consigo navegar pelo resultado ?</DIV>
<DIV> Obrigado novamente...<BR> </DIV>Daniel ® Antunes<BR><EM><FONT color=#007f40>profissional de informática</FONT></EM><BR><EM><FONT color=#007f40>msn</FONT></EM> daniel.legend@terra.com.br<BR><EM><FONT color=#007f40>mobile</FONT></EM> + 55 11 8965 2999<BR><EM><FONT color=#007f40>gnu/linux user</FONT></EM> #238553
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR><BR>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">----- Mensagem original ----<BR>De: Lorn <lorn.br@gmail.com><BR>Para: Cascavel Perl Mongers <cascavel-pm@pm.org><BR>Enviadas: Quinta-feira, 28 de Junho de 2007 17:46:04<BR>Assunto: Re: [Cascavel-pm] XML::Parser Tree<BR><BR>E não se esqueça:
<DIV><BR>
<DIV><B><FONT class=Apple-style-span size=1><SPAN class=Apple-style-span style="FONT-SIZE: xx-large">use strict;</SPAN></FONT></B></DIV>
<DIV><B><FONT class=Apple-style-span size=1><SPAN class=Apple-style-span style="FONT-SIZE: xx-large">use warnings;</SPAN></FONT></B></DIV>
<DIV><BR> </DIV>
<DIV><BR>
<DIV><SPAN class=gmail_quote>On 6/28/07, <B class=gmail_sendername>Gabriel Vieira</B> <<A href="mailto:gabriel.vieira@gmail.com" target=_blank rel=nofollow>gabriel.vieira@gmail.com </A>> wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Opa Daniel!<BR><BR>Faça uso do Data::Dumper :)<BR><BR>------------------------------8<--------------------------- ---<BR>use XML::Parser;<BR>use Data::Dumper;<BR><BR>my $parser=new XML::Parser;<BR>my $p=new XML::Parser(Style => 'Tree');<BR>my $xml=$p->parse('<inquiry>'<BR> .'<city>2</city>'
<BR> .'<region>CENTER</region>'<BR> .'<childages>'<BR> .'<childage>2</childage>'
<BR> .'<childage>11</childage>'<BR> .'</childages>'<BR> .'</inquiry>'); <BR><BR><BR>print Dumper($xml);<BR>------------------------------>8------------------------------<BR><BR>A
saída:<BR>------------------------------8<------------------------------<BR>$VAR1 = [<BR> 'inquiry',
<BR> [<BR> {},<BR> 'city',<BR> [<BR> {},<BR> 0,<BR> '2'<BR> ],<BR> 'region',<BR> [<BR> {},<BR> &nbs
p; 0,<BR> 'CENTER'<BR> ],<BR> 'childages',<BR> [<BR> {},<BR> 'childage',<BR> [<BR> {},<BR> 0,<BR> '2'<BR>
],<BR> 'childage',<BR> [<BR> {},<BR> 0,<BR> '11' <BR> ]<BR> ]<BR> ]<BR> ];<BR>------------------------------>8------------------------------<BR><BR>Abraços,<BR><BR><BR>On 6/28/07, Daniel (r) Antunes <<A
href="mailto:danielrantunes@yahoo.com.br" target=_blank rel=nofollow> danielrantunes@yahoo.com.br</A>> wrote:<BR>><BR>> Olá amigos da lista,<BR>> Estou apanhando com uma bobeirinha e acredito que os amigos possam me<BR>> ajudar.<BR>> Já fiz parsers usando Handlers para grandes documentos e conheço bem o <BR>> funcionamento. Agora estou tentando criar um parser usando a opção "Tree",<BR>> nunca tinha utilizado este método e apesar da simplicidade exposta na "man<BR>> page" estou apanhando.<BR>> Segue um script que fiz para testar o funcionamento :<BR>><BR>> #!/usr/bin/perl<BR>> use XML::Parser;<BR>> my $parser=new XML::Parser;<BR>> my $p=new XML::Parser(Style => 'Tree');<BR>> my $xml=$p->parse('<inquiry>'
<BR>> .'<city>2</city>'<BR>> .'<region>CENTER</region>'<BR>> .'<childages>'
<BR>> .'<childage>2</childage>'<BR>> .'<childage>11</childage>'<BR>> .'</childages>'
<BR>> .'</inquiry>');<BR>> print " 1º\t",$xml,"\n\n";<BR>> print " 2º\t",$$xml[0],"\n\n";<BR>> print " 3º\t",$$xml[1],"\n\n"; <BR>> print " 4º\t",$$xml[1][1],"\n\n";<BR>> print " 5º\t",$$xml[1][2],"\n\n";<BR>> print " 6º\t",$$xml[1][3],"\n\n";<BR>> print " 7º\t",$$xml[1][4],"\n\n"; <BR>> print " 8º\t",$$xml[1][5],"\n\n";<BR>> print " 9º\t",$$xml[1][6],"\n\n";<BR>><BR>> O resultado no console é o seguinte :<BR>><BR>> 1º ARRAY(0x815a0e4) <BR>><BR>> 2º inquiry<BR>><BR>> 3º ARRAY(0x815a180)<BR>><BR>> 4º
city<BR>><BR>> 5º ARRAY(0x8220f90)<BR>><BR>> 6º region<BR>><BR>> 7º ARRAY(0x8220f30)<BR>> <BR>> 8º childages<BR>><BR>> 9º ARRAY(0x82130f4)<BR>><BR>> 10º<BR>><BR>> 11º<BR>><BR>> 12º<BR>><BR>> Minha dúvida é : Como navegar pelos elementos. :(<BR>> Muitíssimo obrigado galera. <BR>> Abraço.<BR>><BR>> Daniel (r) Antunes<BR>> profissional de informática<BR>> msn <A href="mailto:daniel.legend@terra.com.br" target=_blank rel=nofollow>daniel.legend@terra.com.br</A><BR>> mobile + 55 11 8965 2999<BR>> gnu/linux user #238553 <BR>><BR>><BR>> ________________________________<BR>> Novo Yahoo! Cadê? - Experimente uma nova
busca.<BR><BR>> _______________________________________________<BR>> Cascavel-pm mailing list<BR>> <A href="mailto:Cascavel-pm@pm.org" target=_blank rel=nofollow>Cascavel-pm@pm.org</A><BR>> <A href="http://mail.pm.org/mailman" target=_blank rel=nofollow>http://mail.pm.org/mailman</A>/listinfo/cascavel-pm<BR>><BR><BR><BR><BR>--<BR>Gabriel Vieira<BR>_______________________________________________<BR>Cascavel-pm mailing list <BR><A href="mailto:Cascavel-pm@pm.org" target=_blank rel=nofollow>Cascavel-pm@pm.org</A><BR><A href="http://mail.pm.org/mailman" target=_blank rel=nofollow>http://mail.pm.org/mailman</A>/listinfo/cascavel-pm<BR></BLOCKQUOTE></DIV><BR><BR clear=all><BR>-- <BR>Lindolfo "Lorn" Rodrigues <BR>- <A href="http://www.slackwarezine.com.br/" target=_blank rel=nofollow>www.slackwarezine.com.br</A><BR>- <A href="http://lornlab.org/" target=_blank rel=nofollow>http://lornlab.org</A><BR>- <A href="http://sao-paulo.pm.org/" target=_blank
rel=nofollow>http://sao-paulo.pm.org</A><BR>use Catalyst; </DIV></DIV>
<DIV>_______________________________________________<BR>Cascavel-pm mailing list<BR>Cascavel-pm@pm.org<BR><A href="http://mail.pm.org/mailman/listinfo/cascavel-pm" target=_blank>http://mail.pm.org/mailman/listinfo/cascavel-pm</A></DIV></DIV><BR></DIV></div><br>
<hr size=1>Novo <a href="http://yahoo.com.br/oqueeuganhocomisso ">Yahoo! Cadê?</a> - Experimente uma nova busca. </body></html>