newbie_ab has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to replace one element of XML document with a new element using XML::Twig. The element value file does not change in the player.xml. I am new to this module
Here is the code snippet:
use strict; use warnings; use XML::Twig; use Data::Dumper; my $twig = XML::Twig->new(); $twig->parsefile( "player.xml"); # build the twig my $root= $twig->root; $root->set_tag( 'stats_test'); $root->print;
And the sample XML file(player.xml):
<stats> <player> <name>Houston, Allan</name> <g>69</g> <ppg>20.1</ppg> <rpg>3.4</rpg> <apg>2.8</apg> <blk>14</blk> </player> <player> <name>Sprewell, Latrell</name> <g>69</g> <ppg>19.2</ppg> <rpg>4.5</rpg> <apg>4.0</apg> <blk>15</blk> </player> <player> <name>Ewing, Patrick</name> <g>49</g> <ppg>14.6</ppg> <rpg>10.0</rpg> <apg>1.0</apg> <blk>68</blk> </player> <player> <name>Johnson, Larry</name> <g>57</g> <ppg>11.1</ppg> <rpg>5.3</rpg> <apg>2.6</apg> <blk>7</blk> </player> </stats>
Any help will be appreciated . Thanks ab
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Not able to replace element value using XML::Twig
by Anonymous Monk on Jan 24, 2010 at 23:56 UTC | |
by newbie_ab (Novice) on Jan 25, 2010 at 13:48 UTC | |
by toolic (Bishop) on Jan 25, 2010 at 14:19 UTC | |
|
Re: Not able to replace element value using XML::Twig
by jethro (Monsignor) on Jan 25, 2010 at 00:16 UTC | |
by newbie_ab (Novice) on Jan 25, 2010 at 13:52 UTC | |
by jethro (Monsignor) on Jan 25, 2010 at 14:12 UTC | |
by newbie_ab (Novice) on Jan 28, 2010 at 22:39 UTC | |
by jethro (Monsignor) on Jan 29, 2010 at 03:01 UTC | |
|