use strict; use XML::Rules; my $filter = XML::Rules->new( style => 'filter', rules => { 'IntDir,OutDir' => sub { my ($tag,$attr,$context,$parents) = @_; $attr->{_content} =~ s/\bReleaseDLL\b/ReleaseDLL32/ if $context->[-1] eq 'PropertyGroup' && $parents->[-1] +->{Condition} =~ /'Release DLL\|Win32'/; return $tag => $attr; }, } ); $filter->filterfile($inputFilename, $outputFilename);
Or if you want to be correct according to the namespaces
use strict; use XML::Rules; my $filter = XML::Rules->new( style => 'filter', namespaces => { 'http://schemas.microsoft.com/developer/msbuild/2003' => 'ms', '*' => 'keep' }, rules => { 'ms:IntDir,ms:OutDir' => sub { my ($tag,$attr,$context,$parents) = @_; $attr->{_content} =~ s/\bReleaseDLL\b/ReleaseDLL32/ if $context->[-1] eq 'ms:PropertyGroup' && $parents->[ +-1]->{Condition} =~ /'Release DLL\|Win32'/; return $tag => $attr; }, } ); $filter->filterfile($inputFilename, $outputFilename);
Not using XML::LibXML though :-)
Jenda
Enoch was right!
Enjoy the last years of Rome.
In reply to Re: Some questions from beginning user of XML::LibXML and XPath
by Jenda
in thread Some questions from beginning user of XML::LibXML and XPath
by eyepopslikeamosquito
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |