I monks, i have a problem with XML::Twig module, im parsing and reading a xml file in this way:
use XML::Twig;
my $twig = XML::Twig->new(keep_encoding => "true");
$twig->parse("$string");
foreach my $product ($twig->root->children('produto')) {
my $sibling = $product->first_child();
my %produto;
do {
$produto{$sibling->tag()} = $sibling->child_text();
} while($sibling = $sibling->next_sibling());
$product{nome} =~ s/\s+//g;
......................
}
My xml structure is in this way:
<produtos>
<produto>
<codigo>I0000949</codigo>
<nome>Acucareiro Acril 200g Cromus Acrylic Line</nome>
<categoria>SALA DE JANTAR:ACESSÓRIOS PARA MESA</categoria>
<marca>Fabrica da Pedra</marca> <preco></preco>
<link>4,99</link>
<imagem>http://imgproduto.casaevideo.com.br/jpg/ud-cozin/000094
+9b.jpg</imagem>
<parcelamento>
<parcelas>12</parcelas>
<valor>0,53</valor>
</parcelamento>
</produto>
......
</produtos>
And my problem is:
How i can read the data from tags <parcelas> and <valor> is into the tag <parcelamento> ?
Anyone as $product{parcelamento}{parcelas}, but it it dont works.
Thanks,
mvitor
ps: sorry foy my english
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.