Thanks - that works perfectly when operating on 1.xml or another XML document object.
Your sample uncovered another layer/problem: my XML document comes from Net::EPP::Frame (cpan.org says "This module implements a subclass of the XML::LibXML::Document..."), so I'm doing something wrong when I try:
use Net::EPP::Frame;
my $frame = Net::EPP::Frame::Command::Update::Contact->new;
#...
my $xpc = XML::LibXML::XPathContext->new($frame);
$xpc->registerNs('contact', 'urn:ietf:params:xml:ns:contact-1.0');
for my $name (qw(rem add)) {
for my $node ($xpc->findnodes("//contact:$name".'[not(*|text()
+|@*|processing-instruction()|comment())]', $frame->documentElement))
+{
$node = $node->parentNode->removeChild($node);
}
}
print $frame->toString(1);
My thinking is that because Net::EPP::Frame inherits from XML::LibXML::Document, I should be able to operate on $frame (the XML document) similarly to your original solution... but I'm missing something. |