in reply to Replacing an XPath node with the value of its content

Keep fiddling with replaceChild because that is the way to do it.
  1. Build a text-node containing the new content.
  2. Navigate to the parent node and instruct it to replaceChild the existing node with the new text-node.
Remember that the replacement node must be coined from the same document.
  • Comment on Re: Replacing an XPath node with the value of its content

Replies are listed 'Best First'.
Re^2: Replacing an XPath node with the value of its content
by stylechief (Beadle) on Oct 22, 2013 at 00:01 UTC
    Your step #1 was the ticket! Thanks AM. I was not first constructing a new text node.

    The simple fix:
    $parentnode = $node -> parentNode; $txtnode = XML::LibXML::Text ->new($tmtext); $node = $parentnode -> replaceChild($txtnode, $node);
    SC