Trying to extract two strings of information from a xml file. In the example linkage.xml file, I'd like the batch file to run and create a directory Smith-John-yyyy-mm-dd. So far I am able to generate a folder with the date in the format I want (yyyy-mm-dd), but I am unable to extract "Smith" and "John" as variables. Help would be greatly appreciated.
linkage.xml
<LinkageParameter>
<Patient LastName="Smith" FirstName="John" ChartNumber="123">
<Birthday>18/12/1972</Birthday>
<Address>123 Main St, Salem, OR</Address>
<ZipCode>97302</ZipCode>
<Phone>(503)363-5432</Phone>
<Mobile>(503)215-3215</Mobile>
<SocialID>123456789</SocialID>
<Gender>Male</Gender>
</Patient>
</LinkageParameter>
My folder.bat file
@echo off
for /f %%i in ('xml.exe sel -t -v "//LastName" CP.xml') do set var=%%i
for /f %%i in ('xml.exe sel -t -v "//LastName" CP.xml') do set var=%%j
setlocal enabledelayedexpansion
:: Extract date fields - language dependent
for /f "tokens=1-4 delims=/-. " %%i in ('date /t') do (
set v1=%%i& set v2=%%j& set v3=%%k
if "%%i:~0,1%%" gtr "9" (set v1=%%j& set v2=%%k& set v3=%%l)
for /f "skip=1 tokens=2-4 delims=(-)" %%m in ('echo.^|date') do (
set %%m=!v1!& set %%n=!v2!& set %%o=!v3!
)
)
:: Final set for language independency (English and Portuguese - maybe works for Spanish and French)
set year=%yy%%aa%
set month=%mm%
set day=%dd%
md \\192.168.0.34\OpenDentImages\PatientImages\CT\%i%-%j%-%year%-%month%-%day%
xml.exefrom but Windows has native capability to read XML files with Vbscript and Jscript.