Gizmo has asked for the wisdom of the Perl Monks concerning the following question:
I've written two scripts with XML::Simple and XML::DOM to do some replacements they work but with XML::Simple I have a problem with the output being alphabetically sorted which I've read is a limitation. I'm now trying to do the same with XML::Twig but can't seem to figure out how to do it. I've displayed the XML and the Simple code so you can get a better understanding of what I want to achieve. I'm wanting to change the Id= part from Id="/Local/ App/App1" to Id=/App1"
XML snip:XML Simple Code<?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>
use XML::Simple; my $xml = new XML::Simple (ForceArray => 1, KeepRoot => 1,KeyAttr=>[]) +; my $data = $xml->XMLin($xmlfile); my $Id = $data->{Profile}->[0]->{Application}->[0]->{Id}; my $CsID = (split(/\//, $Id))[-1]; $data->{Profile}->[0]->{Application}->[0]->{Id} = $CsID; print $xml->XMLout($data);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: XML::Twig Text replacement
by ikegami (Patriarch) on Apr 30, 2010 at 18:28 UTC | |
by mirod (Canon) on May 01, 2010 at 21:13 UTC | |
by ikegami (Patriarch) on May 02, 2010 at 01:18 UTC | |
by mirod (Canon) on May 03, 2010 at 09:12 UTC | |
by ikegami (Patriarch) on May 03, 2010 at 15:44 UTC | |
by Gizmo (Novice) on May 01, 2010 at 12:16 UTC | |
Re: XML::Twig Text replacement
by toolic (Bishop) on Apr 30, 2010 at 18:29 UTC | |
by ikegami (Patriarch) on Apr 30, 2010 at 18:55 UTC |
Back to
Seekers of Perl Wisdom