Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The documentation also says you must use generate_ns_name(NAME,URI) to define $gs. I can't find an example of calling generate_ns_name or within_element.
My xml file looks like this: ========company.xml======= <comany> <group> <name>dev group 1</name> <product>product 1</product> <product>product 2</product> <product>product 3</product> <product>product 4</product> </group> <group> <name>dev group 2</name> <product>product 1</product> <product>product 2</product> </group> </company>
Thanks,========company.pl======== #!/bin/perl -w use strict; use XML::Twig; my $field= 'group'; my $twig= new XML::Twig; $twig->parsefile( "company.xml"); # build the twig my $root= $twig->root; # get the root of the twig my @group = $root->children; # get the list foreach my $my_group (@group) # the sorted list { print "\nGroup Name: ",$my_group->first_child("name")->text; print "\nGroup Name: ",$my_group->first_child("product")->text; } ================
Edit kudra, 2001-09-24 Removed cpde tags around text
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to use XML::Twig
by mirod (Canon) on Sep 21, 2001 at 20:11 UTC | |
by Novitiatus (Novice) on Sep 21, 2001 at 21:41 UTC | |
by mirod (Canon) on Sep 21, 2001 at 22:03 UTC |