http://www.perlmonks.org?node_id=1211528

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

Hi PerlMonks

I have the following bilingual file and would like to extract the source and target nodes preserving its xml elements they might have as well as the line breaks. Could you please help me on that? I have no experience in xml parsing with Perl.

Here is a sample of my file:

<trans-unit id="1" maxbytes="14"> <source xml:lang="en-US">Hello <x id=1/> world! How are you?</source> <target xml:lang="ja-JP">Ciao<x id=1/> mondo! Come stai?</target> </trans-unit>

The expected result should be:

Hello <x id=1/> world! <lb/> How are you? || Ciao<x id=1/> mondo! <lb/> Come stai?

Thank you for your time!