http://qs321.pair.com?node_id=1212599


in reply to Parsing and manipulating XML

The cow says, "Mooooooooooo…" :P

use strictures; use XML::LibXML; my $doc = XML::LibXML->load_xml( IO => \*DATA ); my $text = [ $doc->findnodes('/Build-Doc/Build/text()[1]') ]->[0]; my $value = $text->data; $value =~ s/text/TACOS/; $text->setData($value); print $doc; __END__ <Build-Doc> <Build> text.mak <Targets>all</Targets> <Nmake></Nmake> </Build> </Build-Doc>

You can work directly with text as XML nodes. Just find the right xpath in your case to it or, if necessary, to iterate over the text items (my example just grabs the first one and puts it in a scalar instead of an array of found nodes). Update: s/list/array/ + missing article.