I selectively capture some elements and attributes. Unfortunately, our input files contain both single and double quotes. In addition, some attribute values ββcontain quotation marks (inside the value).
Using XML :: Twig, I don't see how to keep all quotes around attribute values.
Here is an example code:
use strict; use XML::Twig; my $file=qq(<file> <label1 attr='This "works"!' /> <label2 attr="This 'works'!" /> </file> ); my $fixes=0;
The above code returns invalid XML for label1:
<label1 attr="This "works"!" />
If I add:
$twig->set_quote('single');
Then we will see invalid XML for label2:
<label2 attr='This 'works'!' />
Is it possible to save existing quotes? Or is there a better approach to selectively commit branches?
source share