Page 1 of 1

Replace Strings based on the Line starting with a particular string

Posted: 08 Mar 2022 07:29
by JessicaPearson
Hi All,
Please help to guide me on the below .

I am trying to replace a list of strings in a XML file, the strings are getting replaced but its getting replaced throughout the file, but I am trying to Findstr to replace strings only in the line which starts with <OfferName>, the file is very big and it will have multiple occurrences of <OfferName> tag, so I cannot use the exact line number.

Below is the part of the code which I am currently using , please let me know how can I Include only the lines which start with <OfferName>

Code: Select all

for /f "delims=: tokens=1*" %%a in ('findstr /n "^" "Offer_letter.XML"') do (
  set "line=%%b"
  call :ReplaceStrings

Thanks

Re: Replace Strings based on the Line starting with a particular string

Posted: 08 Mar 2022 11:02
by JessicaPearson
I was able to do a workaround on replacing the required strings but in the replaced file, this non-ascii charcter  is getting added automatically . I have searched on the internet and tried the below method but its not working.

Code: Select all

chcp 65001
ren Input.xml  Output.xml
Please help e on how to not generate this charcter  in the output file

Re: Replace Strings based on the Line starting with a particular string

Posted: 08 Mar 2022 12:51
by JessicaPearson
I was able to figure it out.

Thanks Guys