use strict; use warnings; use 5.016; use XML::LibXML; my $dom = XML::LibXML->load_xml(string => <<'END_OF_XML'); Hello END_OF_XML #Deal with the namespace declared in the svg tag: my $xpc = XML::LibXML::XPathContext->new($dom); $xpc->registerNs('ns', 'http://www.w3.org/2000/svg'); my ($tspan) = $xpc->findnodes('//ns:text/ns:tspan'); #Change the tspan's text: $tspan->removeChildNodes(); $tspan->appendTextNode("Goodbye"); #Prove that the tspan's text changed: say $tspan; say $dom->toString;