erwaga
asked on
Read xml file inside a batch file
Hi,
I want to read a xml file inside a batch file to read a value in specific tag of xml file. The value read from the xml has to be stored a variable inside the batch file.Your help much appreciated.
Thanks in advance
I want to read a xml file inside a batch file to read a value in specific tag of xml file. The value read from the xml has to be stored a variable inside the batch file.Your help much appreciated.
Thanks in advance
Main trouble with reading something like XML from a batch file is the normal parsing is going to get messy with > and < characters in the data. It may be easier to do this in a VB Script frankly? is that an option? If not will see what can be done.
Can you give us the relevant line (at least) of the XML file in question please and what you want to retrieve please.
ASKER
VBScript is not an option. Here is the xml file
<?xml version="1.0" encoding="utf-8" ?>
<ConnectionInfo>
<DTSConfigDB>10.0.244.31</ DTSConfigD B>
</ConnectionInfo>
I have to read value in <DTSConfigDB>
<?xml version="1.0" encoding="utf-8" ?>
<ConnectionInfo>
<DTSConfigDB>10.0.244.31</
</ConnectionInfo>
I have to read value in <DTSConfigDB>
Ok. Not so bad then maybe...
@echo off
for /f "tokens=2 delims=><" %%a in ('type test.xml ^| find
"<DTSConfigDB>"') do set ip=%%a
echo The IP address is %ip%
Steve
@echo off
for /f "tokens=2 delims=><" %%a in ('type test.xml ^| find
"<DTSConfigDB>"') do set ip=%%a
echo The IP address is %ip%
Steve
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It really works, thanks Steve for prompt response.
No problem!