Modify in xml in multiple files

1

Hello,

I need to modify a value inside an xml node, the problem is that I need to do this in 1300 files at one time, the value I look for inside the node can be any one, it does not matter what value it is there, just need to modify this node in all files at once, for example:

Em um xml pode estar
    <VDesc>9.32</vDesc>
Em outro
    <VDesc>1.45</vDesc>

Em assim por diante.

Preciso modificar em todos arquivos para
    <VDesc>0.00</vDesc>

That's it, any suggestions, what tool to use?

    
asked by anonymous 05.09.2016 / 16:29

2 answers

2

Based on all the answers I was able to solve the problem in a simple and very effective way, I did the following:

With Notepad ++

Option Find - Replace , ", in the Find field I put

<vICMSDeson>(\s*\d+\.\d+\s*)<\/vICMSDeson>

, and in the Replace with field,

<vICMSDeson>0.00</vICMSDeson>

In Filters I put: * .xml to search only for xml files, then Folder I indicated the path of the xml files, in Search mode I selected "Regular expression". Perfect.

Maybe it will be useful for someone else.

Thanks to everyone

    
24.10.2016 / 05:12
0

If you can use perl, here's a suggestion:

perl -i -pe 's!<VDesc>.*?</VDesc>!<VDesc>0.00</VDesc>!s' *.xml

If you prefer to create a backup of the original (a.xml, a.xml.bak):

perl -i.bak -pe 's!<VDesc>.*?</VDesc>!<VDesc>0.00</VDesc>!s' *.xml

(I assumed the V, v to be V)

    
05.09.2016 / 19:02