通过批处理文件中提取从XML文件中的文本 [英] Extracting text from XML file via batch file
本文介绍了通过批处理文件中提取从XML文件中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须通过一个批处理文件来提取一个XML文件中的某些文本。一个我需要提取的部分是字符串变量之间(<串>例1< /串>
),另一个是数据标签(之间<数据>例2< /数据>
)。任何想法如何?在此先感谢!
解决方案
@echo OFF德尔output.txt的FOR / Fdelims =%% i的('FINDSTR / I / C:<串gt;中xml_file.xml')也称:工作%%我
GOTO:EOF:工作集线=%1集线=%行:/ =%
集线=%线:其中= +%
集线=%行:> = +%
集线=%行:* +字符串+ =%
集线=%行:+ =放大器; REM%
回声%行%方式>> output.txt的:EOF
与OP的输入输出文件 -
D:\\> draft.batD:\\>键入output.txt的
000000000@gmail.com
默认
Web表单密码
www.instagram.com(000000000@gmail.com)www.instagram.com
干杯,G
I have to extract certain text from an XML file via a batch file. One of the parts I need to extract is between string tags (<string>example1</string>
) and the other is between data tags (<data>example2</data>
). Any ideas how? Thanks in advance!
解决方案
@echo OFF
del output.txt
for /f "delims=" %%i in ('findstr /i /c:"<string>" xml_file.xml') do call :job "%%i"
goto :eof
:job
set line=%1
set line=%line:/=%
set line=%line:<=+%
set line=%line:>=+%
set line=%line:*+string+=%
set line=%line:+=&rem.%
echo.%line%>>output.txt
:eof
Output with OP's input file-
D:\>draft.bat
D:\>type output.txt
000000000@gmail.com
default
Web form password
www.instagram.com (000000000@gmail.com)
www.instagram.com
Cheers, G
这篇关于通过批处理文件中提取从XML文件中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文