Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Some questions from beginning user of XML::LibXML and XPath

by Jenda (Abbot)
on Oct 17, 2012 at 14:10 UTC ( #999547=note: print w/ replies, xml ) Need Help??


in reply to Some questions from beginning user of XML::LibXML and XPath

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.


Comment on Re: Some questions from beginning user of XML::LibXML and XPath
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999547]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2015-07-07 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls