Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

XML::Twig demo for Przemek

  • Loading branch information...
commit 5e9897fd23205368561cf118645256e058e79365 1 parent 0d94777
Jay Hannah authored
Showing with 46 additions and 0 deletions.
  1. +17 −0 Przemek/go.pl
  2. +29 −0 Przemek/input.xml
17 Przemek/go.pl
View
@@ -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 Przemek/input.xml
View
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.