1

I'm trying to extract a version number out of an XML file. The XML file contains as string with:

<!-- Full version --> <key id="about_fullVersion">10.1.5</key>

Using:

FINDstr /I "about_fullVersion" C:\PLM\Teamcenter10\install\versionlocal.xml >>%logfile%

I can extract the complete line and send it to the log file. How can I strip the version number from this find so that I only send the version# to the logfile ?

I also tried

FOR /f "tokens=*" %%a in ('FINDstr /I "about_fullVersion" C:\PLM\Teamcenter10\install\versionlocal.xml') do (set var=%%a)
echo.%var% >>%logfile%

but it does not parse to the variable.

Arjen
  • 13
  • 4
  • 1
    I am glad you have something that works for you. In general, scanning HTML/XML with cmd scripts, or even regexes, is a fool's errand. See https://stackoverflow.com/questions/6751105/why-its-not-possible-to-use-regex-to-parse-html-xml-a-formal-explanation-in-la and https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – lit Jun 07 '18 at 16:27

1 Answers1

1
set VAR=&
for /f "usebackq tokens=2 delims=<>" %%v in (`
  findstr /i "about_fullVersion" C:\PLM\Teamcenter10\install\versionlocal.xml
`) do if not defined VAR set VAR=%%v
echo VAR="%VAR%"
AlexP
  • 4,370
  • 15
  • 15
  • @Arjen: If the answer has solved the problem then please accept it, so that future readers know that it worked. – AlexP Jun 07 '18 at 12:00