Batch script to read .xml

Microsoft Windows 2003 server - 5 users
June 16, 2010 at 17:35:38
Specs: Windows Server 2003
Hello Experties,

I am bit new in batch scriptting,

I am trying to retrieve string from myfile.xml into variable.

I want to have only Date (01/01/2010 )


<Header FileDate="01/01/2000"/>
<Body Type="Firm">
<Dept Firmid="0123" Name="abc"/>
<Trailer RecordCount="1">

for that I am using

for /F "tokens=2 delims= " %%i IN ('findstr /L "FileDate" D:\temp\myfile.xml) do call set var1=%%i

set loaddate= %var1:~10,10%

echo %loaddate%

once it will get load in var1 i have to run java command by passing parameter value of loaddate.

javacommand %var1%

but I am not getting date(01/01/2010) in var1

Please heelp me out to solve this problem.

Really appereciate in advance for any suggesion.


See More: Batch script to read .xml

Report •

June 16, 2010 at 20:16:26
I cheated a bit by setting up another delimiter, essentially
erasing the ">" from the input string:
for /F "tokens=2 delims=^> " %%i IN (...

the carat (^) escapes the function of ">", a special character
which typically redirects output. Hope this helps!

Also note that I added the closing ' within the IN ( ) statement, and removed the space after the = in "set loaddate=", but perhaps the embedded space is indeed wanted...

Report •

June 16, 2010 at 21:09:53
Hi Orangeboy,

Thank you for instant response.

It worked for me perfectly.

You r rock!!!

Thnk you once again.


Report •

Related Solutions

Ask Question