xml is available in a file, it will be very similar to this.
<AppName>
<Action AllDay='1' StartRace='1'/>
<StartPoint AM_PM='AM' Hours='09' Mins='30'/>
<EndPoint AM_PM='PM' Hours='06' Mins='30'/>
</AppName>
I have written a perl script to change the Hours of StartPoint tag,
Expand|Select|Wrap|Line Numbers
- use strict;
- use warnings;
- use XML::Twig;
- my $fileName = 'Conf.xml'
- my $twig = XML::Twig->new(
- twig_roots => { StartPoint => \&ReplaceAtriValue },
- twig_print_outside_roots => 1,
- );
- sub ReplaceAtriValue {
- my ($twig, $startPoint) = @_;
- if ( '09' eq $startPoint->att('Hours') )
- {
- $startPoint->set_att( Hours => '12');
- }
- $startPoint->print();
- }
- $twig->parsefile($fileName);
Actually I have using XML::XPath for long back hence I have to send the XML::XPath object to all my own *.pm like SetWindow.pm, at the same time i need to change the values of the attribute of the standard xml before sending to my own PMs.
Thanks in Advance
Any Help is much appreciated