in reply to XML::Twig Text replacement
use strict; use warnings; use XML::Twig; my $x = <<EOF; <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <Profile xmlns="xxxxxxxxx" name="" version="1.1" xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance"> <Application Name="App1" Id="/Local/App/App1" Services="1" pol +icy="" StartApp="" Bal="5" sessInt="500" WaterMark="1.0"/> <AppProfileGuid>586e3456dt</AppProfileGuid> </Profile> EOF my $t = XML::Twig->new(twig_handlers => {Application => \&app}); $t->parse($x); $t->print(); sub app { my ($twig, $app) = @_; my $id = $app->att('Id'); $id =~ s{^/Local/App}{}; $app->set_att('Id', $id); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML::Twig Text replacement
by ikegami (Patriarch) on Apr 30, 2010 at 18:55 UTC |