in reply to Parsing XML file and keeping the formatting tags

Your input is not a valid XML. The id=1 should be id="1". After fixing that, the following seems to work for the input you showed:
#!/usr/bin/perl use warnings; use strict; use XML::LibXML; my $dom = 'XML::LibXML'->load_xml(location => 'file.xml'); for my $child ( @{ $dom->find('/trans-unit/*[self::source | self::target]') } ) { ( my $contents = join '', $child->childNodes ) =~ s,\n, <lb/> ,g; print $contents, $child->nodeName eq 'source' ? ' || ' : "\n"; }
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Parsing XML file and keeping the formatting tags
by corfuitl (Sexton) on Mar 22, 2018 at 18:56 UTC

    Thank you so much

    I added the " and it works :)

    However, I would like to have a deeper understanding of the code as I am not familiar. I will check it and will get back if any questions will arrise.

    Thanks

      This is not a code problem, it is a problem with incorrect formatting of XML data.

      Like any structured data format, you must stick with the standard, and ensure it is correct. Perhaps some programs will work with bad XML/JSON etc data, but properly written applications and modules will not (and should not imho).