Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: XML round-trip with comments and prolog

by haukex (Bishop)
on Jul 28, 2021 at 18:31 UTC ( #11135442=note: print w/replies, xml ) Need Help??


in reply to XML round-trip with comments and prolog

But my next goal was to round-trip the config file

My experience with XML::Rules was that, sadly, it is not good at round-tripping XML files (Update: see also Jenda's comments here). IMHO, if that's what you want, I'd just go with XML::LibXML, in conjunction with its XPath support it's not too difficult to pull values out of the config file while maintaining the original XML file's structure. An alternative might be XML::Twig, though my experience with that is more limited.

  • Comment on Re: XML round-trip with comments and prolog

Replies are listed 'Best First'.
Re^2: XML round-trip with comments and prolog
by pryrt (Monsignor) on Jul 28, 2021 at 19:19 UTC
    Thanks. I have occasionally muddled through XPath terms for a very specific experiment, but it just doesn't stick with me, so I was hoping to avoid it. But I guess I'll try going down that path for this; maybe because I this will likely be more than a one-time script for me, I might remember more of the concepts (especially XPath) that I learn this time through.

    The good news is, I can at least get a super-simple round-trip with comments:

    ... use XML::LibXML; my $dom = XML::LibXML->load_xml(string => $xml_doc); print $dom->toString(), "-----\n"; # works!

    ... so that's something. ;-)

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2022-05-21 13:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (76 votes). Check out past polls.

    Notices?