Solved CMD BAT Script use variable from XML file

June 4, 2013 at 01:33:51
Specs: Windows XP, 4 Gigs
Hello all,

I hope somebody can help me.
Ive following challange:

I need to write a CMD Script that will read a specific string from an XML file and use it as a variable.
Lets assume:
my XML is located here:


and the line from which I need the specific value looks like this:

<field level = "system" name = "Document count in batch" value = "10"/>

I want to have the String 10 as a variable.
Problem is, 10 can be also 1 and also 100 (length varies)

I tried with findstr command, but there I found just an option to look for specifc position.
Is there a way to find string based on pattern?

something like this:

findstr "Document count in batch" value = "%thisIsMyVariable%"/>

Many thanks,
any Help is highly appreciated

See More: CMD BAT Script use variable from XML file

Report •

June 4, 2013 at 01:49:33
✔ Best Answer
:: ===== script starts here ===============
:: XMLvar.bat 2013-06-04 15:39:32.95
@echo off & setLocal enableDELAYedeXpansioN

for /f "tokens=13 delims= " %%a in ('find "Document count in batch" ^< myfile') do (
set S=%%a
set S=!S:"=!
set S=!S:~0,-2!
set myvar=!S!
echo !myvar!
goto :eof
::====== script ends here =================

M2 Golden-Triangle

Report •

June 4, 2013 at 05:39:23
Mechanix2Go - You made my Day!! Thanks

Report •
Related Solutions

Ask Question