Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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 browsing the Monastery: (7)
As of 2014-07-31 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (245 votes), past polls