Click here to Skip to main content
14,367,095 members
Rate this:
Please Sign up or sign in to vote.
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 2: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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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[^]
   
v2

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100