Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an xml with multiple tags. I want to replace the values of 2 tags with some different values in windows batch file.

I tried below one. But in this case only "arr_name " is getting replaced.
I want to replace both "arr-id" and "arr_name".

Please help.

What I have tried:

(for /F "delims=" %%b in (!filename!) do (
   set "line=%%b"
   set "arr_id=!line:<value>subst_arrangement_name=!"
   if "!arr_id!" neq "!line!" (
      set "arr_id=<value>123"
   )
   set "arr_name=!line:<value>subst_filename=!"
   if "!arr_name!" neq "!line!" (
      set "arr_name=<value>Test"
   )
   echo !arr_id!
   echo !arr_name!
  
)) > !newCoreXML!
Posted
Updated 8-Nov-19 1:20am
v2
Comments
RickZeeland 8-Nov-19 7:16am    
Could you add a (small) example of the xml file you want to change ?

1 solution

It is probably simpler to use Powershell for such things, see example here: How can you find and replace text in a file using the Windows command-line environment? - Stack Overflow[^]

If you prefer a DOS batch file, see: DOS Batch - File Examples[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900