Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

LibXML: Change a node into a comment

by dominic01 (Sexton)
on Apr 04, 2013 at 06:36 UTC ( [id://1026937]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1026937]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found