dominic01 has asked for the wisdom of the Perl Monks concerning the following question:

I am new to XML::LibXML but not to Perl. I have an XML similar to

<start> <a>text<b>test</b>more text<c>text</c></a> <d>text</d> </start>

Now I need to comment the node <a> like

<start> <!--<a>text<b>test</b>more text<c>text</c></a>--> <d>text</d> </start>

Appreciate any help

Replies are listed 'Best First'.
Re: LibXML: Change a node into a comment
by choroba (Cardinal) on Apr 04, 2013 at 07:58 UTC
    Using XML::XSH2, a wrapper around XML::LibXML:
    open 1.xml ; insert comment xsh:serialize(/start/a[1]) prepend /start ; delete /start/a[1] ;
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: LibXML: Change a node into a comment (replace)
by Anonymous Monk on Apr 04, 2013 at 06:42 UTC