Parse an XML file

Posted on 2016-10-12
Last Modified: 2016-11-01
I'm trying to parse an XML file, I need to be able to pass a single parameter to a batch file "DEV2_BUSINESSAPPS_URL", if found I want the "" returned. Unfortunately it has to be a batch file.

Here is my XML file:

Open in new window

Question by:Jeff Melies
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 34

Expert Comment

ID: 41841669
A batch (file) is a collection of directives for an interpreter. What interpreter do you have in mind? bash, csh, zsh, 4nt, cmd, ps?
LVL 33

Accepted Solution

shalomc earned 500 total points (awarded by participants)
ID: 41841736
In any scenario you will need an XML parser.
You could write code in your favourite language and run it in batch. Alternatively create a XSLT or Xquery and use an external tool like Saxon to run it.  

Here is an example in python. Python has executables on all platforms.
import  xml.etree.ElementTree as  xml

# you should pass is as a parameter

# assuming the xml file is called env.xml
e = xml.parse('env.xml').getroot()

# the naive way, but it works
for variable in e.findall("Variable"):
	if name==lookup:
		print name, value

# use xpath to search		
for variable in e.findall("./*[Name='%s']" % (lookup) ):
	print name, value

Open in new window

LVL 33

Expert Comment

ID: 41868071
No further input from author, but it is a valid solution.

Featured Post

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API ( has made its way into the popular lexicon of the English language.  A few years ago, …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question