I tried using findnode, but I get an error about perl not being able to find that method. So, thanks for the pointer! It at least is getting me the results I want. :)#!/usr/bin/perl use strict; use warnings; use XML::LibXML; die "Usage: $0 filename \n"; unless ( @ARGV > 0 ); my $xml_file = shift; my $xml = XML::LibXML->new; my $dom = $xml->parse_file( $xml_file ); my $root = $dom->documentElement; my @logins = grep { $_->nodeType == XML_ELEMENT_NODE } $root->childNod +es; foreach my $login ( @logins ) { my @user_infos = grep { $_->nodeType == XML_ELEMENT_NODE } $login-> +childNodes; foreach my $user_info ( @user_infos ) { my @add_users = grep { $_->nodeType == XML_ELEMENT_NODE } $user_ +info->childNodes; foreach my $add_user ( @add_users ) { $add-user->removeAttribute( "USER_NAME" ); $add-user->removeAttribute( "PASSWORD" ); } } } my $output = $dom->toString(0); $output =~ s/(?<=\n)\s*\n//g; open ( my $FH, '>', 'newilo2' ) or die "Could not open file newilo2 $! +"; print $FH $output; close $FH;
In reply to Re^2: xml remove attribute
by BradV
in thread xml remove attribute
by BradV
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |