I have a below line in a pom.xml file.
<abc>xyz</abc>
I need to extract xyz by doing a pattern matching using batch script same like sed -e 's/(.*)/\1/'
and the output should be xyz.
Can anyone please help?
I have a below line in a pom.xml file.
<abc>xyz</abc>
I need to extract xyz by doing a pattern matching using batch script same like sed -e 's/(.*)/\1/'
and the output should be xyz.
Can anyone please help?
You can use <> as delims.
@for /f "tokens=2delims=>< " %%i in ('type pom.xml') dodo set "result=%%i" & goto :show
:show
echo %result%
or if you want a specific value only based on the property name of the tag..
@for /f "tokens=2delims=>< " %%i in ('type pom.xml ^| find /I "abc"') do set "result=%%i" & goto :show
:show
echo %result%
you can try with xpath.bat:
call xpath.bat pom.xml "//abc"
to save it to a variable:
for /f "tokens=* delims=" %%# in ('xpath.bat pom.xml "//abc"') set "abc_value=%%#"
echo %abc_value%