Extracting text from XML file via batch file

本小妞迷上赌 提交于 2019-12-01 21:01:04
@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

Try this:

@echo off
setlocal EnableDelayedExpansion

(for /F "delims=" %%a in ('findstr /I /L "<string> <data>" theFile.xml') do (
   set "line=%%a"
   set "line=!line:*<string>=!"
   set "line=!line:*<data>=!"
   for /F "delims=<" %%b in ("!line!") do echo %%b
)) > result.txt

Check the xpath.bat script:

call xpath.bat "xml.xml" "//data"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!