I'm trying to get the strings between 2 tags in an XML file adapting a solution I found in here.
This is the batch file I've:
@echo off
setlocal EnableDelayedExpansion
(for /F "delims=" %%a in ('findstr /I /L "<Name>" contacts.xml') do (
set "line=%%a
set "line=!line:*<Name>=!"
for /F "delims=<" %%b in ("!line!") do echo %%b
)) > list.txt
Now when the XML is formatted I get all the names
<List>
<Contacts>
<Row>
<Name>Carlos</Name>
<Path>\Some\path\1</Path>
<Hidden>False</Hidden>
</Row>
<Row>
<Name>Fernando</Name>
<Path>\Some\path\2</Path>
<Hidden>False</Hidden>
</Row>
<Row>
<Name>Luis</Name>
<Path>\Some\path\3</Path>
<Hidden>False</Hidden>
</Row>
<Row>
<Name>Daniel</Name>
<Path>\Some\path\4</Path>
<Hidden>False</Hidden>
</Row>
</Contacts>
</List>
Carlos
Fernando
Luis
Daniel
But when the XML(This is how it's generated) is in 1 line I only get the first name
<List><Contacts><Row><Name>Carlos</Name><Path>\Some\path\1</Path><Hidden>False</Hidden></Row><Row><Name>Fernando</Name><Path>\Some\path\1</Path><Hidden>False</Hidden></Row><Row><Name>Luis</Name><Path>\Some\path\1</Path><Hidden>False</Hidden></Row><Row><Name>Daniel</Name><Path>\Some\path\1</Path><Hidden>False</Hidden></Row></Contacts></List>
Carlos
What changes should I make to the batch file so it correctly parse unformatted XML files?