Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2005, 03:26 PM
Registered User
 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to parse env variables

Hi,
In my xml file i have a variable setup as this:
<Logfile path="$(CONFIG.DIR)" />

I have an env variable setup in my windows XP as this:
CONFIG_DIR=C:\MyApp\cfg

In my code for parsing xml i have the following:
org.w3c.dom.Element el = (org.w3c.dom.Element) nodeList.item(0);
m_sPath = el.getAttribute("path");

The variable m_sPath returns null. Any idea what am i doing wrong. Or can anyone suggest how i can get env variables from an xml config file? Help would be greatly appreciated. Thanks.


 
Old March 31st, 2005, 05:16 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

The code you have shown should return the value "$(CONFIG.DIR)", a string, if the nodeList contains the Logfile element as its first child. XML has no way to evaluate environment variables. You can parse the string to get "CONFIG.DIR" and then use standard Java methods (I assume this is Java, I've never seen org.w3c.dom.Element before) to resolve this variable.



--

Joe (Microsoft MVP - XML)
 
Old March 31st, 2005, 08:06 PM
Registered User
 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Joe,
Your reply is helpful to me. I am using Java. Could you tell me, if once i get the "Config.dir" string, what java functions could i use to get the "CONFIR_DIR" value? Thanks.

 
Old April 1st, 2005, 06:00 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I don't know if there is a cross platform way. Better to ask in the Java forums and state what platform you are running on.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Parse error: parse error, unexpected T_STRING geminient PHP How-To 4 August 18th, 2007 02:27 AM
Parse error: parse error, unexpected $end Ayodeji Adegbaju Pro PHP 3 January 12th, 2007 12:21 PM
Window.open from OnClick event in framed env. nancy Javascript How-To 3 December 22nd, 2004 11:30 AM
Using .NET classLib in VB6 env aslyon General .NET 1 September 27th, 2004 09:36 AM
how to get env variable values? suri Java Databases 1 September 20th, 2003 05:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.