#!/usr/bin/perl use strict; use warnings; use XML::LibXML; # Define file paths my $input_file = '1.xml'; my $output_file = '3.xml'; # Create a new XML::LibXML object my $parser = XML::LibXML->new; # Parse the input XML file my $doc = $parser->parse_file($input_file); # Example transformation: let's say we want to add an attribute to the root element my $root = $doc->documentElement(); $root->setAttribute('newAttribute', 'newValue'); # Example transformation: change the value of an element foreach my $node ($doc->findnodes('//someElement')) { $node->removeChildNodes(); $node->appendText('New Value'); } # Save the transformed XML to the output file $doc->toFile($output_file); print "Transformation complete. Output saved to $output_file\n";