1

My problem isn't just having to do this across multiple files, but it is also that the complexity of what I need to find is quite tricky. After upgrading the .NET version of my application, some parts of some resource files have been duplicated, for everything except the assembly version number which has been incremented.

Here is an example resource file, which should demonstrate my problem:

<data attribute="value" >
    <value>Version="dot_net_4_assembly_version_number", <!--This element is fine--></value>
</data>

<data attribute="anotherValue" >
    <value>Version="dot_net_2_assembly_version_number", "identical_data_here"</value>
</data>

<data attribute="anotherValue" >
    <value>Version="dot_net_4_assembly_version_number", "identical_data_here"</value>
</data>

So what I would need is some sort of tool, or some command script or something(if this is even possible) which will search through each file, and identify wherenall values in xml elements are the same, except the Version=... numbers match the .NET 2 and 4 versions, and then remove the .NET 2 version of the xml element.

How to achieve this? Would some sort of bash-command script be needed to do this? (Also, hopefully I am asking this question in the right place, let me know if I am not)

  • 1
    Notepad++ seems to be the right tool for the job. What OS are you using? – LPChip Jan 9 '17 at 11:27
  • Also, asking for software is off-topic here on SuperUser. But because you ask for any method, scripts included, it is on-topic. You may need to edit your post because others may still consider this to be off-topic, due to how you state your question. – LPChip Jan 9 '17 at 11:28
  • @LPChip Win10. Didn't even think to consider Notepad++, I just assumed it wouldn't have such features. Thanks for the tip on the relevance and "off-topicness" here on SuperUser too, any advice on how to re-word the question specifically? – Danny Goodall Jan 9 '17 at 11:33
  • 1
    Replace "I need some sort of tool, or..." for "How can I" – LPChip Jan 9 '17 at 12:08
0

You can do quite complex find-and-replace actions with regular expressions and (for example) Notepad++. However, this might not be feasible when the file you are trying to change don't have items saved the exact same way.

Personally, since the file is XML, I would simply use a programming environment, like the one you are used to, to write a problem to read and write the XML files. That might be probably a lot easier than to write a complex regular expression.

Alternatively, you could use XML->XSLT to read the files and transform them, but I would go for the option that which I am most familiar to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.