07-23-2023, 11:04 AM
I am parsing a XML file like below:
<?xml version="1.0"?>
<!--
-->
<configuration>
<settings>
<connections>
<connection name="name1" value="connection1" type="abc"/>
<connection name="name2" value="connection2" type="def"/>
</connections>
</settings>
</configuration>
From the batch file, I prompt the user for connection name. I want to parse the XML get a connection with the specified name and get its value. So If user gives name1, I want to select connection1. I had the below code from
I am not familiar with for loop in (especially delimits, tokens) batch file, so I am not sure how this works and how to make it work for me.
(for /F "tokens=1,2 delims== " %%a in (connection.config) do (
if "%%~b" neq "" set %%a=%%~b
if /I "!name!" equ "%name%" echo !value!
))
<?xml version="1.0"?>
<!--
-->
<configuration>
<settings>
<connections>
<connection name="name1" value="connection1" type="abc"/>
<connection name="name2" value="connection2" type="def"/>
</connections>
</settings>
</configuration>
From the batch file, I prompt the user for connection name. I want to parse the XML get a connection with the specified name and get its value. So If user gives name1, I want to select connection1. I had the below code from
[To see links please register here]
I am not familiar with for loop in (especially delimits, tokens) batch file, so I am not sure how this works and how to make it work for me.
(for /F "tokens=1,2 delims== " %%a in (connection.config) do (
if "%%~b" neq "" set %%a=%%~b
if /I "!name!" equ "%name%" echo !value!
))