my problem is something which I have been unable to solve after several days of futile searching. I'm very new to XML or any other sort of programming so excuse any mistakes I make explaining!

Essentially, as is said in the title, I need to replace all of the numbers within the parentheses

< Scale_Factor > < /Scale_Factor >

to be a third of their original value. How, in notepad++, XML editor, or any other programmes that you might be familiar with, can I do this? Is there actually a way? All help is much appreciated! Example of the numbers is 3.0. I want to change it to 1.0. The numbers vary throughout the document. XML version 1.0

2

There are 2 best solutions below

0
On

Well matching the numbers isn't too hard. You will just have to use the regular expression search and do something like this:

\<Scale_Factor\>([A-Za-z\.\s]*)([d]+)([A-Za-z\.\s]*)\<\/Scale_Factor\>

Matching this regex would allow you to replace all the numbers if you replaced it with something like this: \1 (something to replace nums) \3

However, you are not allowed to do math in the replace statements, so you're out of luck here. Your best bet would be to just replace the numbers with iterative replace commands or write a custom exe to do it for you.

0
On

This is a simple problem but it is difficult to do if you don't know how to code. Here is the simplest solution specific to your problem.

Create a file called divide.xsl and put the following data in it:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes" />
  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>
  <xsl:template match="Scale_Factor">
    <xsl:copy>
      <xsl:value-of select="text() div 3" />
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

Using Notepad++, with xmltools plugin installed. Open your xml file, go to Plugins >> XML Tools >> XSL Transformation and open the divide.xsl you just created. Tada!

There are many solutions to this problem. This solution is done through XSLT and XPath. Look at this and this for more info.