[Python] is it possible to find/replace entire XML elements in Oxygen without messing up the...

Discussão em 'Python' iniciado por Stack, Agosto 31, 2025.

  1. Stack

    Stack Membro Participativo

    I'm new to an Epidoc XML project, still learning the basics of XML. My supervisor has asked me to add elements inside elements. This is intended to be a bulk operation adding the same date to the same specific bibliographic entry across a large number of files.

    What I've tried so far is thus, using the 'Find/Replace in files' option:

    1. Find an instance of the element that I need to add the date to, and copying that entire element into both the 'find' and 'replace' fields
    2. Add the element into the version in the 'replace' field, so that it replaces the entire element with the updated element that now includes the date

    This works, except for the fact that it removes newlines in the replaced element. I have to go back in and manually add a new line everywhere that it is needed. I have tried looking into regular expressions, using e.g. '\n' but that hasn't worked so far. Weirdly, using the find/replace function in just one file seems to give me more options, but that's useless to me as it's a big bulk operation.

    I'm open to solving this in another XML editor or perhaps even using python, but I'm a relative beginner in both XML and python so I've not found solutions online that make sense to me. Any help is hugely appreciated!

    Continue reading...

Compartilhe esta Página