Text editor that can replace everything between tags?

Discussion in 'Programming/Scripts' started by BenjaminLucas, May 7, 2020.

  1. BenjaminLucas

    BenjaminLucas New Member

    I am busy importing a lot of advertisements from 1 system to another using xml.
    I need to change the xml file a lot, so I need a function that replaces everything between tags.
    For instance: <id>236862</id> to nothing 184 times with different id's.
    Or <titulo></titulo> to <title>Example Title</title>

    Which linux text editor has this function?

    Thank you!
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Any text editor that has search and replace can handle that.
    This is trickier. You need regular expression to match <id>...</id>, and be prepared tags in the pair may not be in the same line. I would do this using sed or write a script that does the replace, and would not try to find a text editor that supports this kind of thing. If it has to be text editor, Emacs of course can do it.
     
  3. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

  4. Steini86

    Steini86 Active Member

    ahrasis likes this.
  5. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    That is if he is using linux cli, which is a good way.

    I had developed android apps before and based on many xml files to be edited, he could be developing one.

    I edited about 600 files, 200 at a time simply using Notepad ++, so I'd say it is quite good.

    However, linux will be my preferred choice / platform to develop the same in the future as it definitely has so much more to offer once you get used to it.
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Jeremy007 and ahrasis like this.
  7. Steini86

    Steini86 Active Member

    (bold by me)
    But: I just looked it up, notepad++ is indeed available for linux via snap packages. However, imho there are better text editors for linux. But they require more of a learning curve.
     
    till likes this.
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Oh, yes. Missed that he was looking for a Linux editor.
     
  9. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    you could use vi, it's included by default in pretty much every Linux distribution as far as i'm aware.
    and it'll do pretty much any text/regex manipulation, syntax formatting/highlighting, etc that you could possibly dream of.

    unfortunately, it's not so much got a (steep) learning curve, more a vertical line... ;)
     

Share This Page