How to remove extra lines in a XML file using perl

Discussion in 'Perl Misc' started by pambouy2, Nov 20, 2005.

  1. pambouy2

    pambouy2 Guest

    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
     
    pambouy2, Nov 20, 2005
    #1
    1. Advertisements

  2. pambouy2

    pambouy2 Guest

    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>
     
    pambouy2, Nov 20, 2005
    #2
    1. Advertisements

  3. wrote in @g49g2000cwa.googlegroups.com:
    Have you tried using XML::TokeParser?

    Sinan
     
    A. Sinan Unur, Nov 20, 2005
    #3
  4. pambouy2

    Matt Garrish Guest

    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
     
    Matt Garrish, Nov 21, 2005
    #4
  5. pambouy2

    usenet Guest

    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?
     
    usenet, Nov 21, 2005
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.