Skip to content

Commit

Permalink
XML::Twig demo for Przemek
Browse files Browse the repository at this point in the history
  • Loading branch information
jhannah committed Jul 21, 2010
1 parent 0d94777 commit 5e9897f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Przemek/go.pl
@@ -0,0 +1,17 @@
use strict;
use XML::Twig;

my $twig = XML::Twig->new();
$twig->parsefile('input.xml');
my $root = $twig->root;
foreach my $imp ($root->children('important')) {
my $name = $imp->att('name');
my $arg = $imp->first_child('imp_arg')->att('arg');
my $ele = $imp->first_child('imp_element')->text;
print join ",", $name, $arg, $ele;
print "\n";
}




29 changes: 29 additions & 0 deletions Przemek/input.xml
@@ -0,0 +1,29 @@
<document>
<smth>xxx</smth>
<important name="1">
<imp_arg arg="a"></imp_arg>
<not_imp arg= "123"></not_imp>
<imp_element>"A"</imp_element>
</important>
<important name="2">
<imp_arg arg= "b"></imp_arg>
<not_imp arg= "123"></not_imp>
<imp_element>"B"</imp_element>
</important>
<important name="3">
<imp_arg arg= "c"></imp_arg>
<not_imp arg= "123"></not_imp>
<imp_element>"C"</imp_element>
</important>
<important name="4">
<imp_arg arg= "d"></imp_arg>
<not_imp arg= "123"></not_imp>
<imp_element>"D"</imp_element>
</important>
<important name="5">
<imp_arg arg= "e"></imp_arg>
<not_imp arg= "123"></not_imp>
<imp_element>"E"</imp_element>
</important>
<nothing_special></nothing_special>
</document>

0 comments on commit 5e9897f

Please sign in to comment.