vincebrown
Technical User
Could someone please tell me how to write a script that searches an .xml file and insert a string between two xml tags? Thanks.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
open FILE, "your_xml.xml";
foreach(<FILE>){
push (@file,$_);
}
close FILE;
unlink "your_xml.xml";
open FILE, ">your_xml.xml";
foreach (@file){
if ($_ =~ /(.*)<PreprocessorFlags>/){
print FILE "$_ $1\t/U_CPPUNWIND\n";
}else{
print FILE $_;
}
}
close FILE;
open FILE, 'your_xml.xml';
foreach(<FILE>){
push (@file,$_);
}
close FILE;
unlink 'your_xml.xml';
open FILE, '>your_xml.xml';
foreach (@file){
if ($_ =~ /(.*)(<PreprocessorFlags>)(.*)/){
print FILE " $1\t$2/U_CPPUNWIND$3\n";
}else{
print FILE $_;
}
}
close FILE;