I need to extract the Value from a specific xml tag in all the xml files in a folder and export the value and file name w/o ext in 2 separate columns in a csv file. I have tried the follow with zero luck.
The xml looks like this:
<ICSMXML xmlns="http://www.icsm.com/icsmxml" version="1.0">
<Header>
<MsgDelivery>
<To>
<Credential>
<Domain>ICSMID</Domain>
<Identity>11</Identity>
</Credential>
</To>
<From>
<Credential>
<Domain>DUNS</Domain>
<Identity>039576814</Identity>
</Credential>
</From>
<Sender>
<Credential>
<Domain>DUNS</Domain>
<Identity>039576814</Identity>
</Credential>
<UserAgent />
</Sender>
</MsgDelivery>
<MsgHeader>
<MessageId>10000095713</MessageId>
<Timestamp>04/12/2013 10:24:00 AM</Timestamp>
I need to parse the value from MessageId in any xml file found in the folder, and out put that in to an csv file along with the original file name w/o ext. preferably have the value in column 1 and the file name w.o ext in column 2.
@echo off
call :check_lines < %1 > "%~N1.xml"
exit /b
REM Seek for the start of Data tag
:check_lines
set /P line=
if not "%line%" == "<MessageId>" goto check_lines
REM Copy until the end of Data tag
set /P line=
:put_lines
if "%line%" == "</MessageId>" goto end_lines
set /P line=%line%
goto put_lines
:end_lines
echo %line%
>>Message.csv