此外,純一批
set "init="
set "term="
for /F "tokens=1,* delims=[]" %%A in ('type yourFile.xml ^| find /I /N "placemark"') do (
if not defined init (set /a init=%%A) else (set /a term=%%A)
)
for /F "tokens=1,* delims=[]" %%A in ('type yourFile.xml ^| find /N /V "^"') do (
if %%A GEQ %init% if %%A LEQ %term% echo/%%B
)
編輯:這個問題是在的type
前報價線for /F "tokens=1,* delims=[]" %%A in ('type yourFile.xml ...
和寫入到文件
set "init="
set "term="
for /F "tokens=1,* delims=[]" %%A in ('type yourFile.xml ^| find /I /N "placemark"') do (
if not defined init (set /a init=%%A) else (set /a term=%%A)
)
>"myFile.txt" (
for /F "tokens=1,* delims=[]" %%A in ('type yourFile.xml ^| find /N /V "^"') do (
if %%A GEQ %init% if %%A LEQ %term% echo/%%B
)
)
因此,任何echo ...
打印到MYFILE.TXT
雖然也許可以用了很大的力氣,我強烈建議使用標準的Windows移植* nix中'grep',與該解決方案可以歸結爲'grep的-A2-B2「STRING」文件。 txt'。得到它[這裏](http://gnuwin32.sourceforge.net/packages/grep.htm)。 – zb226