How to remove extra lines in a XML file using perl

P

pambouy2

Hi,

I'm trying to find a way to remove extra line in a XML file as
described below:
Change the file below:
<people>
<name>John Doe</name>
<phone>21212121215</phone>
<address> 75 Rue de Marshall
Boulevard Attarde
453 France</address>
</people>
<people>
<name>Jeanne Doe</name>
<phone>21212121215</phone>
<address> 55675 Astor Place
Boulevard Testritou
96000 France</address>
</people>

into the file below:
<people>
<name>John Doe</name>
<phone>21212121215</phone>
<address> 75 Rue de Marshall Boulevard Attarde 453
France</address>
</people>
<people>
<name>Jeanne Doe</name>
<phone>21212121215</phone>
<address> 55675 Astor Place Boulevard Testritou 96000
France</address>
</people>

Thanks for helping me, it's pretty urgent!

Regards,

Yanis
 
P

pambouy2

Sorry, Quick correction. See below what i'm trying to do:
Change the file below:
<people>
<name>John Doe</name>
<phone>21212121215</phone>
<address> 75 Rue de Marshall
Boulevard Attarde
453 France</address>
</people>
<people>
<name>Jeanne Doe</name>
<phone>21212121215</phone>
<address> 55675 Astor Place
Boulevard Testritou
96000 France</address>
</people>

into the file below:
<people>
<name>John Doe</name>
<phone>21212121215</phone>
<address> 75 Rue de Marshall Boulevard Attarde 453
France</address>
</people>
<people>
<name>Jeanne Doe</name>
<phone>21212121215</phone>
<address> 55675 Astor Place Boulevard Testritou 96000
France</address>
</people>
 
A

A. Sinan Unur

(e-mail address removed) wrote in @g49g2000cwa.googlegroups.com:
I'm trying to find a way to remove extra line in a XML file as
described below: ....

Thanks for helping me, it's pretty urgent!

Have you tried using XML::TokeParser?

Sinan
 
M

Matt Garrish

Sorry, Quick correction. See below what i'm trying to do:
Change the file below:

It would be more helpful in the future if you stated explicitly what it is
you're trying to do ("I want to remove all linefeeds and compact the
whitespace in the <address> element", for example), rather than expect
people to compare your examples. You might also want to consider providing
more context to your problem. If you think someone is going to write a
program for you, expect to be sorely disappointed. If you show the code
you're having difficulty with and say what parser you're using and what size
files you're dealing with, you'll probably get a much better response.

Matt
 
U

usenet

Change the file below:
<people>
<name>John Doe</name>
<phone>21212121215</phone>
<address> 75 Rue de Marshall
Boulevard Attarde
453 France</address>
</people>
into the file below:
<people>
<name>John Doe</name>
<phone>21212121215</phone>
<address> 75 Rue de Marshall Boulevard Attarde 453 France</address>
</people>

As far as I can see, you're not "removing any lines" - you're just
removing line breaks in the <address> section. Is this your intent?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top