Community
    • Login

    Bulk Editing Values in XML Files

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 2.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      ashiruni
      last edited by ashiruni

      Hello!

      I’ve got a bit of a niche situation that comes up annoyingly often for me when modding: I need to bulk edit values within an entry in an XML file.

      So, say I have the entry <hitpoints>****.**</hitpoints>. Whatever the value of the asterisks is, regardless of the formatting (decimals or whatnot), needs to be modified by a multiplier and then repeated across all entries until the end of the document. As far as I’m aware I’ll need to use a python script, but I’ve very limited prior experience with python, so I don’t know what that would like or how to integrate it into Notepad++.

      Any help would be appreciated!

      PeterJonesP CoisesC 2 Replies Last reply Reply Quote 1
      • PeterJonesP
        PeterJones @ashiruni
        last edited by PeterJones

        @ashiruni said in Bulk Editing Values in XML Files:

        needs to be modified by a multiplier
        … As far as I’m aware I’ll need to use a python script

        Correct. See the FAQ: Can I do a Mathematical Replacement. It gives examples of how to do simple math replacements in the PythonScript plugin (it shows addition, but I think you can figure out how to change it to multiplication; the FAQ also links to another FAQ to show you how to set up the PythonScript plugin and run an example script). The regex needed to catch something in the <hitpoints> tag as you showed would be <hitpoints>(\d+\.\d+)</hitpoints>

        1 Reply Last reply Reply Quote 0
        • CoisesC
          Coises @ashiruni
          last edited by

          @ashiruni said in Bulk Editing Values in XML Files:

          So, say I have the entry <hitpoints>****.**</hitpoints>. Whatever the value of the asterisks is, regardless of the formatting (decimals or whatnot), needs to be modified by a multiplier and then repeated across all entries until the end of the document.

          If you can reliably identify the value to be multiplied using a regular expression, the Columns++ plugin can do this.

          After installing the plugin, you would select Search… from the Columns++ menu, then fill in:

          Find what : <hitpoints>([\d.]+)</hitpoints>
          Replace with : <hitpoints>(?=reg(1)*n)</hitpoints>
          Search Mode: Regular Expression

          (replacing n with the multiplier) and then click Replace All.

          Detailed help for Search and Formulas is available. This plugin is not yet available through Plugins Admin, but you can use the Quick Installer at the first link if you have Notepad++ installed in the default location; otherwise, install as explained here.

          A 1 Reply Last reply Reply Quote 4
          • A
            ashiruni @Coises
            last edited by

            @Coises

            This is exactly what I was hoping for. Python is well and good, but I haven’t dived into it for good reason. Thanks for letting me know this exists ^.^

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors