Perl XML :: LibXML - search&重新发送textContent

时间:2013-10-30 16:16:16

标签: perl xml-libxml

正如标题所说,我只想迭代每个文本节点并搜索&替换一个值。我怎么能用XML :: LibXML做到这一点?

use warnings;
use strict;
use XML::LibXML qw(XML_ELEMENT_NODE XML_ATTRIBUTE_NODE XML_TEXT_NODE);

my $parser = XML::LibXML->new({keep_blanks => 0 });
my $dom = $parser->load_xml(location => 'walkDOM.xml') or die;

foreach my $fndval2 ($dom->findnodes('//*'))
{
 foreach my $child ( $fndval2->getChildnodes()) 
 {
  if ($child->nodeType eq 3)  **# still can't figure-out how to use keyword instead** 
  {
   **<<  right here I like to search/grep for value and replace >>**   
   print "NodeName: ", $fndval2->nodeName(), " VALUE: ", $child->textContent, "\n";
  }
 }
}

0 个答案:

没有答案