parse xml using a batch file



i have been working with this idea as listed here


Parse XML file for attribute from batch file


But i cant comment to ask for more questions so i am asking for more help and this is not really a duplicate cause i changed several things


So my channelGuide.xml looks like this



<Guide>
<listings>
<channels>
<channel ID='1' name='big bang' url='http://v.com/bigbang' quality='best' />
<channel ID='2' name='AMerican Dad' url='http://ift.tt/1udeHOJ' quality='best' />
</channels>
</listings>
</Guide>


now my .bat file looks like this:



@echo off
cls
setlocal EnableDelayedExpansion

for /F tokens^=2^-9^,7delims^=^<^"^= %%a in (channelGuide.xml) do (
if "%%a" equ "channel ID" echo(%%b %%c %%d %%e>>"%~d0%~p0\channelListings.txt"
)


but for some reason my .tx is coming back like this:



'1' name 'big bang' url 'http://v.com/bigbang' quality 'best' />
'2' name 'AMerican Dad' url 'http://ift.tt/1udeHOJ' quality 'best' />


I do not want the single quotes or anything but to look exactly like this:



1 big bang http://v.com/bigbang best
2 AMerican Dad http://ift.tt/1udeHOJ best

No comments:

Post a Comment