I'm trying to read an xml file and read STRING "50" between the build tags from a XML file. I tried it but I'm not getting any output.
The XML file..
<?xml version="1.0" encoding="UTF-8"?>
<CDMDataXML xmlns="http://www.avocent.org/trellis/CDMLoaderXMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.avocent.org/trellis/CDMLoaderXMLSchema CDMLoaderXMLSchema.xsd">
<CDMDataVersion>
<Major>1</Major>
<Minor>0</Minor>
<Build>50</Build>
<Delimiter>.</Delimiter>
</CDMDataVersion>
The batch file code..
@ECHO OFF
SETLOCAL
SET "build="&SET "grab="
FOR /f "tokens=*" %%a IN (version.xml) DO (
IF DEFINED grab SET build=%%a&SET "grab="
IF /i "%%a"=="<BUILD>" SET grab=Y
)
ECHO found build=%build%
GOTO :EOF
Will the code run if the xml file and the batch file are situated in the same folder and i execute the batch file from cmd???
EDIT 1:
@MC ND I made the changes you mentioned and ran the code.When i hit enter, the cursor moves to the next line and gets stuck there.I doesn't give any output as well. I'm not able to close the cmd window also. All this is explained in the image file below.
ANSWER
As suggested by MCND below I renamed my file to findx.bat which is returning the value "50" which is what i wanted.The screen-shot of the correct output is given below.
Thanks a lot @MCND!!