473,513 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Nested XML files using Nini

I'm using Nini from http://nini.sourceforge.net to read and write XML
files. I'm having trouble creating nested 'configs' (Sections)
however.

This is a sample of my code....

----- vb.net -----
Dim srcData As XmlConfigSource = New XmlConfigSource
Dim Config As IConfig

Config = srcData.AddConfig("foo_01")
Config = srcData.AddConfig("Counters")
Config.Set("counter_01", "1")
Config.Set("counter_02", "2")
Config.Set("counter_03", "3")

Config = srcRomData.AddConfig("Timers")
Config.Set("timer_01", "01:00")
Config.Set("timer_02", "02:00")
Config.Set("timer_03", "03:00")

srcData.Save("data\roms\" & RomName & "\" & RomName & ".xml")
-----

The output I get is like this....

----- xml ------
<Nini>
<Section Name="foo_01" />
<Section Name="Counters">
<Key Name="counter_01" Value="1" />
<Key Name="counter_02" Value="2" />
<Key Name="counter_03" Value="3" />
</Section>
<Section Name="Timers">
<Key Name="timer_01" Value="01:00" />
<Key Name="timer_02" Value="02:00" />
<Key Name="timer_03" Value="03:00" />
</Section>
</Nini>
-----

However, what I want to accoumplish is...

----- xml ------
<Nini>
<Section Name="foo_01">
<Section Name="Counters">
<Key Name="counter_01" Value="1" />
<Key Name="counter_02" Value="2" />
<Key Name="counter_03" Value="3" />
</Section>
<Section Name="Timers">
<Key Name="timer_01" Value="01:00" />
<Key Name="timer_02" Value="02:00" />
<Key Name="timer_03" Value="03:00" />
</Section>
</Section>
</Nini>
-----

Basically, I want everything nested in 'foo_01'. Can anyone with Nini
experience please help me?

Many thanks,
Quan

Dec 15 '06 #1
3 2035
Try:

Dim foo_01 As IConfig = srcData.AddConfig("foo_01")
Dim Config as IConfig = foo_01.AddConfig("Counters")
Config.Set("counter_01", "1")
Config.Set("counter_02", "2")
Config.Set("counter_03", "3")
Config = foo_01.AddConfig("Timers")
Config.Set("timer_01", "01:00")
Config.Set("timer_02", "02:00")
Config.Set("timer_03", "03:00")
<mr******@hotmail.comwrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...
I'm using Nini from http://nini.sourceforge.net to read and write XML
files. I'm having trouble creating nested 'configs' (Sections)
however.

This is a sample of my code....

----- vb.net -----
Dim srcData As XmlConfigSource = New XmlConfigSource
Dim Config As IConfig

Config = srcData.AddConfig("foo_01")
Config = srcData.AddConfig("Counters")
Config.Set("counter_01", "1")
Config.Set("counter_02", "2")
Config.Set("counter_03", "3")

Config = srcRomData.AddConfig("Timers")
Config.Set("timer_01", "01:00")
Config.Set("timer_02", "02:00")
Config.Set("timer_03", "03:00")

srcData.Save("data\roms\" & RomName & "\" & RomName & ".xml")
-----

The output I get is like this....

----- xml ------
<Nini>
<Section Name="foo_01" />
<Section Name="Counters">
<Key Name="counter_01" Value="1" />
<Key Name="counter_02" Value="2" />
<Key Name="counter_03" Value="3" />
</Section>
<Section Name="Timers">
<Key Name="timer_01" Value="01:00" />
<Key Name="timer_02" Value="02:00" />
<Key Name="timer_03" Value="03:00" />
</Section>
</Nini>
-----

However, what I want to accoumplish is...

----- xml ------
<Nini>
<Section Name="foo_01">
<Section Name="Counters">
<Key Name="counter_01" Value="1" />
<Key Name="counter_02" Value="2" />
<Key Name="counter_03" Value="3" />
</Section>
<Section Name="Timers">
<Key Name="timer_01" Value="01:00" />
<Key Name="timer_02" Value="02:00" />
<Key Name="timer_03" Value="03:00" />
</Section>
</Section>
</Nini>
-----

Basically, I want everything nested in 'foo_01'. Can anyone with Nini
experience please help me?

Many thanks,
Quan

Dec 15 '06 #2
Thanks for the reply,

When I try this code I get the following error:...

'AddConfig' is not a member of 'Nini.Config.IConfig'.

It happens at both instances of:...

foo_01.AddConfig("foo_01")

I've been searching through the intellitext and found two items that
*might* be in the right direction...?

Nini.Config.ConfigBase
Nini.Config.ConfigCollection

The Nini documentation doesn't have any examples for anything but the
basic procedures, so I'm having trouble figuring this out. Any help is
much appreciated!

Many thanks,
Quan
Stephany Young wrote:
Try:

Dim foo_01 As IConfig = srcData.AddConfig("foo_01")
Dim Config as IConfig = foo_01.AddConfig("Counters")
Config.Set("counter_01", "1")
Config.Set("counter_02", "2")
Config.Set("counter_03", "3")
Config = foo_01.AddConfig("Timers")
Config.Set("timer_01", "01:00")
Config.Set("timer_02", "02:00")
Config.Set("timer_03", "03:00")
<mr******@hotmail.comwrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...
I'm using Nini from http://nini.sourceforge.net to read and write XML
files. I'm having trouble creating nested 'configs' (Sections)
however.

This is a sample of my code....

----- vb.net -----
Dim srcData As XmlConfigSource = New XmlConfigSource
Dim Config As IConfig

Config = srcData.AddConfig("foo_01")
Config = srcData.AddConfig("Counters")
Config.Set("counter_01", "1")
Config.Set("counter_02", "2")
Config.Set("counter_03", "3")

Config = srcRomData.AddConfig("Timers")
Config.Set("timer_01", "01:00")
Config.Set("timer_02", "02:00")
Config.Set("timer_03", "03:00")

srcData.Save("data\roms\" & RomName & "\" & RomName & ".xml")
-----

The output I get is like this....

----- xml ------
<Nini>
<Section Name="foo_01" />
<Section Name="Counters">
<Key Name="counter_01" Value="1" />
<Key Name="counter_02" Value="2" />
<Key Name="counter_03" Value="3" />
</Section>
<Section Name="Timers">
<Key Name="timer_01" Value="01:00" />
<Key Name="timer_02" Value="02:00" />
<Key Name="timer_03" Value="03:00" />
</Section>
</Nini>
-----

However, what I want to accoumplish is...

----- xml ------
<Nini>
<Section Name="foo_01">
<Section Name="Counters">
<Key Name="counter_01" Value="1" />
<Key Name="counter_02" Value="2" />
<Key Name="counter_03" Value="3" />
</Section>
<Section Name="Timers">
<Key Name="timer_01" Value="01:00" />
<Key Name="timer_02" Value="02:00" />
<Key Name="timer_03" Value="03:00" />
</Section>
</Section>
</Nini>
-----

Basically, I want everything nested in 'foo_01'. Can anyone with Nini
experience please help me?

Many thanks,
Quan
Dec 15 '06 #3
I've been searching high and low and still have found no solution to
nesting structures in XML using Nini. In fact, I've noticed that
Nini's approach to the XML structure mimics an INI file, in that they
only allow one level of structures. I guess this is to simplify the
conversion between config file types.

I'll just have to re-think some areas of my application to work with
this limitation.

Many thanks,
Quan

MrQuan wrote:
Thanks for the reply,

When I try this code I get the following error:...

'AddConfig' is not a member of 'Nini.Config.IConfig'.

It happens at both instances of:...

foo_01.AddConfig("foo_01")

I've been searching through the intellitext and found two items that
*might* be in the right direction...?

Nini.Config.ConfigBase
Nini.Config.ConfigCollection

The Nini documentation doesn't have any examples for anything but the
basic procedures, so I'm having trouble figuring this out. Any help is
much appreciated!

Many thanks,
Quan
Stephany Young wrote:
Try:

Dim foo_01 As IConfig = srcData.AddConfig("foo_01")
Dim Config as IConfig = foo_01.AddConfig("Counters")
Config.Set("counter_01", "1")
Config.Set("counter_02", "2")
Config.Set("counter_03", "3")
Config = foo_01.AddConfig("Timers")
Config.Set("timer_01", "01:00")
Config.Set("timer_02", "02:00")
Config.Set("timer_03", "03:00")
<mr******@hotmail.comwrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...
I'm using Nini from http://nini.sourceforge.net to read and write XML
files. I'm having trouble creating nested 'configs' (Sections)
however.
>
This is a sample of my code....
>
----- vb.net -----
Dim srcData As XmlConfigSource = New XmlConfigSource
Dim Config As IConfig
>
Config = srcData.AddConfig("foo_01")
Config = srcData.AddConfig("Counters")
Config.Set("counter_01", "1")
Config.Set("counter_02", "2")
Config.Set("counter_03", "3")
>
Config = srcRomData.AddConfig("Timers")
Config.Set("timer_01", "01:00")
Config.Set("timer_02", "02:00")
Config.Set("timer_03", "03:00")
>
srcData.Save("data\roms\" & RomName & "\" & RomName & ".xml")
-----
>
The output I get is like this....
>
----- xml ------
<Nini>
<Section Name="foo_01" />
<Section Name="Counters">
<Key Name="counter_01" Value="1" />
<Key Name="counter_02" Value="2" />
<Key Name="counter_03" Value="3" />
</Section>
<Section Name="Timers">
<Key Name="timer_01" Value="01:00" />
<Key Name="timer_02" Value="02:00" />
<Key Name="timer_03" Value="03:00" />
</Section>
</Nini>
-----
>
However, what I want to accoumplish is...
>
----- xml ------
<Nini>
<Section Name="foo_01">
<Section Name="Counters">
<Key Name="counter_01" Value="1" />
<Key Name="counter_02" Value="2" />
<Key Name="counter_03" Value="3" />
</Section>
<Section Name="Timers">
<Key Name="timer_01" Value="01:00" />
<Key Name="timer_02" Value="02:00" />
<Key Name="timer_03" Value="03:00" />
</Section>
</Section>
</Nini>
-----
>
Basically, I want everything nested in 'foo_01'. Can anyone with Nini
experience please help me?
>
Many thanks,
Quan
>
Dec 16 '06 #4

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

Similar topics

2
1585
by: lobrys | last post by:
Hello Here is my question : I have a vb.net appli (Dotnet 1.1). I have a config file that contains personnal settings (myApplication.exe.config) I also have a another config file ( anotherSettings.config ) based in the same structure of a normal configuration file. It contains global settings.
3
1204
by: Rubén Campos | last post by:
Organizing classes, types, structures, enums and whatever other entities into nested namespaces requires to include into every header and implementation file the complete path of namespaces. Let me show an example: classes.hpp classes.cpp util.hpp util.cpp main.cpp // classes.hpp namespace Classes { class MyBaseClass {
2
9429
by: Alfonso Morra | last post by:
I have a (largish) "master" header file (>130 loc). I also have a number of seperate "satelite" header files which declare various objects used by the object declared in the "master" header file. In a clean design, these "satelite" objects (i.e. declared in the satellite header files), should really be nested classes within the master file. ...
8
16859
by: Robert W. | last post by:
I've almost completed building a Model-View-Controller but have run into a snag. When an event is fired on a form control I want to automatically updated the "connnected" property in the Model. This works fine if all of the properties are at the top (root level) of the model but I'd like to keep them in nested classes to organize them...
5
10581
by: Oleg Subachev | last post by:
Are there good classes to work with .INI-files from C# ? Oleg Subachev
0
1099
by: Stefan L | last post by:
Hi everybody! I was just starting to use partial classes in my projects, but it is kind of anoying that the VS solution explorer displays the files flat in the hierachy rather than nested. Example: I have a file (and class) Foo.cs that I want to split in a main part and a part, where extrenal interfaces are implemented (maybe...
2
2801
by: GISmatters | last post by:
I have unbound checkboxes in a nested gridview to allow multi-selection of "child" rows. For context, the parent gridview rows are for large "reports", the child rows are for various specific files comprising each report. I want the user to be able to select an arbitrary collection of report files and have them emailed by clicking an "Email...
13
2098
by: JRough | last post by:
I got lost on formatting the nested if/else's on the bottom of the file right up the last else/if there seems to be a stray bracket. I'm trying to line up the brackets so I can read it. Is it okay to split a long line setting a variable on two lines at the equals sign? That is so you can read it in google groups. <? //Send payement...
4
1873
by: henry | last post by:
Folks: Using Dreamweaver CS3... Consider a home page, "index.php" which conditionally REQUIREs one of 'N' HTML files of pure content. All site styles are specified in a master CSS file, "siteformatting.css" The home page, "index.php" must link to the master CSS file, so that HTML elements in this file can conform to site-wide...
0
7397
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. ...
1
7128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
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...
0
5704
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4759
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...
0
3255
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
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
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.