Windows 10

Batch File To Read XML File

In this tutorial, we are going to see how to read XML file by using For Loop. The batch file contains a series of DOS (Disk Operating System) instructions. It allows triggering the execution of commands found in this file.
 

Sample XML File:
<?xml version="1.0" encoding="utf-8"?>

    
		    Alex
    
    
		    20
    
    
Boston

 

 

Batch File To Read XML File

Before reading an XML file you should download XML.EXE and use it within batch to read an XML file. To download XML.EXE go to http://xmlstar.sourceforge.net/download.php. The following example read the variable “Name” from the XML file “file.xml”:

@echo off

for /f %%i in ('XML.EXE sel -t -v "//Name" file.xml') do set var=%%i
echo Name is %var%

Output:

Name is Alex

 

Leave a Reply

Your email address will not be published. Required fields are marked *