473,660 Members | 2,459 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to read XML configuration parameters, bool, int, double, string

Hello,

I am new to java and need to write a program that uses an XML file for its
configuration. I have an equivalent C++ program that uses libxml2 from
gnome for this task. I wrapped this up in a class (libxml2 is a C
interface). I am wondering how people solve this problem in java.

Googling reveals a tonne of xml configuration projects all pulling in
different directions with different dependencies. The ones that stick out
(IMHO) are JFig, JConfig and Carbon. Can anyone make any recommendations
please?

Ideally the solution should offer the ability to specify the name of a
file that contains the XML, and provide functions to get named attributes
as boolean, integer, double or string values. These functions need to be
able to take an optional default value. Where the configuration value is
missing from the config file and no default has been specified there must
be a means of communicating this to the caller.

Regards,

Andrew Marlow
--
There is an emerald here the size of a plover's egg!
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
Mar 7 '07 #1
1 6231
On Wed, 07 Mar 2007 16:23:05 +0100, Andrew Marlow wrote:
Hello,

I am new to java and need to write a program that uses an XML file for its
configuration. I have an equivalent C++ program that uses libxml2 from
gnome for this task. I wrapped this up in a class (libxml2 is a C
interface). I am wondering how people solve this problem in java.
For anyone who's interested, I found out how to do this: use JDOM.

--
There is an emerald here the size of a plover's egg!
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
Mar 23 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9500
by: Programmer | last post by:
This may sound easy and it probably is, I just started learning C++. I have a class that writes to a file and I would like to add a second optional parameter that will be used to tell the class if a newline character should be written so the next output will start on a new line. My class looks like this: class Debug { public: Debug();
10
13340
by: BCC | last post by:
Hi, I have a tab separated value table like this: header1 header2 header3 13.455 55.3 A string 4.55 5.66 Another string I want to load this guy into a vector of vectors, since I do not know how long it may be. I think I have to have a vector of vectors of strings, and then extract the doubles later(?):
4
8038
by: James Aguilar | last post by:
Hey all, I'm working on an encoding scheme where I am running into a problem with reading a file off a stream. Looking at the binary encoding of the file (using a simple hex editor), there is no problem, and the whole file is there. However, when I try to read it from cin, at certain times, cin stops reading. I cannot force cin to go around the bad character, nor, indeed, do I know what the bad character is. I am including code at...
1
1260
by: José Joye | last post by:
Hello, I'm having a problem with CCW and method parameters. Some of the parameters are classes. It seems that these classes (or at least the properties inside the class) are not seen from my VB client Do I have to declare an interface for these classes (eg. TransModes)? If yes, does anyone know the syntax?
8
3036
by: cody | last post by:
Why doesn't C# allow default parameters for methods? An argument against I hear often is that the default parameters would have to be hardbaken into the assembly, but why? The Jit can take care of this, if the code is jitted the "push xyz" instructions of the actual default values can be inserted. To make things simpler and better readable I'd make all default parameters named parameters so that you can decide for yourself why one to...
1
5346
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; Anybody able to give me idea how-to read by C# element which I add to the machine.config into the new single section?
3
15962
by: Brett Romero | last post by:
I'd like to use some of the techniques discussed here for reading a config file in .NET 2.0: http://msdn.microsoft.com/msdnmag/issues/06/06/ConfigureThis/default.aspx Here's my app.config content: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections>
6
2303
by: gwell | last post by:
Hi, I have a C# assembly that is calling directly into C++ unmanaged code. Everything is working fine but at the very end of the process I get an application error, which says: "The instruction at (hexNumber) referenced memory at (hexNumber). The memory could not be read. Click on OK to terminate the program."
0
2883
by: vishnu | last post by:
Hi, Am trying to post the data over https and am getting error in httpwebresponse.getResponseStream.Please help me to get rid of this issue. Here is the message from immediate window ?myResp.GetResponseStream() {System.Net.ConnectStream}
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8754
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2760
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.