用批处理截取XML档案中两个关键字符串之间的内容
123.XML内容:-10811520148903YIEEAEFNRCBBNCjEwIEFQVSEFNRCBSYWRlb24gUjMgR3JhcGhpY3MgICAAFA...
123.XML 内容: -
1081152014890
3
YIEEAEFNRCBBNCjEwIEFQVSEFNRCBSYWRlb24gUjMgR3JhcGhpY3MgICAAFAAYABwAIAAnoAwAAAOBMaAANCQIlAYAHOASJ4YEAAAAAAAxE
截取后的内容输入到456.ini档案中为: YIEEAEFNRCBBNCjEwIEFQVSEFNRCBSYWRlb24gUjMgR3JhcGhpY3MgICAAFAAYABwAIAAnoAwAAAOBMaAANCQIlAYAHOASJ4YEAAAAAAAxE
123.XML 内容:
- <Key>
<ProductKeyID>1081152014890</ProductKeyID>
<ProductKeyState>3</ProductKeyState>
<HardwareHash>YIEEAEFwIEFQVSB3aXRoIEFNRCBSYWRlb24ggICAgAAACAAMABAAFAAYABwAIAAnoAwAAAOBMaAANCQIlAYAHOASAAAAxE</HardwareHash>
</Key>
截取后的内容输入到456.ini档案中为:YIEEAEFwIEFQVSB3aXRoIEFNRCBSYWRlb24ggICAgAAACAAMABAAFAAYABwAIAAnoAwAAAOBMaAANCQIlAYAHOASAAAAxE(也就是<HardwareHash>与</HardwareHash>之间的内容) 展开
1081152014890
3
YIEEAEFNRCBBNCjEwIEFQVSEFNRCBSYWRlb24gUjMgR3JhcGhpY3MgICAAFAAYABwAIAAnoAwAAAOBMaAANCQIlAYAHOASJ4YEAAAAAAAxE
截取后的内容输入到456.ini档案中为: YIEEAEFNRCBBNCjEwIEFQVSEFNRCBSYWRlb24gUjMgR3JhcGhpY3MgICAAFAAYABwAIAAnoAwAAAOBMaAANCQIlAYAHOASJ4YEAAAAAAAxE
123.XML 内容:
- <Key>
<ProductKeyID>1081152014890</ProductKeyID>
<ProductKeyState>3</ProductKeyState>
<HardwareHash>YIEEAEFwIEFQVSB3aXRoIEFNRCBSYWRlb24ggICAgAAACAAMABAAFAAYABwAIAAnoAwAAAOBMaAANCQIlAYAHOASAAAAxE</HardwareHash>
</Key>
截取后的内容输入到456.ini档案中为:YIEEAEFwIEFQVSB3aXRoIEFNRCBSYWRlb24ggICAgAAACAAMABAAFAAYABwAIAAnoAwAAAOBMaAANCQIlAYAHOASAAAAxE(也就是<HardwareHash>与</HardwareHash>之间的内容) 展开
1个回答
展开全部
@echo off&&setlocal enabledelayedexpansion
set /p cpall=<2.xml
call :getsub %cpall%
set cpall=!__retval!
call :getnext %cpall%
echo !__retval!>3.xml
pause
goto :eof
:getsub
for /f "tokens=1,* delims=:=" %%a in ("%*") do (
if "%%a"=="<HardwareHash>" (
set __retval==%%b
) else (
call :getsub %%b
)
)
goto :eof
:getnext
for /f "tokens=1,* delims=A" %%a in ("%*") do (
set a=%%b
if "</HardwareHash>"=="%a:~0,15%" (
set __retval=!tmpall!
) else (
if "!tmpall!" == "" (
set tmpall=!tmpall!%%a
) else (
set tmpall=!tmpall!A%%a
)
call :getnext %%b
)
)
goto :eof
追问
2.xml 是什么? 3.xml是什么? 123.xml 是全部内容 456.ini是结果
追答
2.xml是你原来的文件
3.xml是截取内容的文件
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询