xmlbatch-file

Batch file to read the contents of an xml file


I have an XML file named example.xml. The content of it is:

<xml>
  <name>Wasif Hasan</name>
  <country>Bangladesh</country>
</xml>

Is there any way to read it using batch file like this:

Name: Wasif Hasan
Country: Bangladesh

Solution

  • Given your provided file content, you should be able to treat it like any normal text file using tokens and delimiters:

    @(For /F "Tokens=2-3Delims=<>" %%A In ('^""%__AppDir__%find.exe" "</"^<"example.xml" 2^>NUL^"')Do @Echo(%%A: %%B)&Pause
    

    Open up a Command Prompt window and enter both for /? and "%__AppDir__%find.exe" /? to read each command's usage information.