このファイルhttp://techpatterns.com/downloads/firefox/useragentswitcher.xml から txt ファイルにブラウザーを一覧表示し、%tab% 区切り記号で区切るのを手伝ってくれません か?
3 つまたは 4 つの列があるはずです。
1) サンプルデータからのフォルダの説明: <folder description="Browsers - Windows">
2) サンプルデータからのブラウザタイプ:<folder description="Legacy Browsers">
3) サンプルデータからのユーザーエージェント:<useragent description="Avant Browser 1.2" useragent="Avant Browser/1.2.789rel1 (http://www.avantbrowser.com)" app
ここで、一部のブラウザーはフォルダーでは<folder description="Legacy Browsers">"
なく、下にあるため、最初の問題が表示されます<separator/>
したがって、1 列目はシステムを定義し、2 列目はタイプ、3 列目はブラウザーを定義する必要があります。
次の問題は、Devises フォルダーにもう 1 つのフォルダーが含まれていることです。
@echo off
Setlocal EnableDelayedExpansion
SET file=useragentswitcher.xml
SET delim="
FOR /F "tokens=* skip=1" %%F IN (!file!) DO (
REM echo %%F
call :parse "%%F" > temp.txt
FOR /F "tokens=1,2,3,4,5,6,7 skip=1 delims=" %%A IN (temp.txt) DO (
IF "%%A"=="folder" (
SET /A level=!level!+1
echo Level:!level!
) ELSE IF "%%A"=="/folder" (
SET /A level=!level!-1
echo Level:!level!
)
echo A:%%A
)
pause
)
exit /b
:parse
Setlocal EnableDelayedExpansion
SET A=%*
REM REMOVE double paranthesis and <>
SET A=!A:~2,-2!
REM replace double qoutes
SET A=!A:"=µ!
FOR /F "tokens=1,2 delims=µ=" %%A IN ("!A!") DO (
SET first=%%A
SET second=%%B
echo !first!
FOR /F "tokens=1,2 delims= " %%A IN ("!first!") DO (
echo %%A
echo %%B
)
echo !second!
)
endlocal
exit /b
これにより、行の 1 つのタグが解析されます。これから作業を進めます。