473,406 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

XML to save some settings

hi there,

i never used XML beforre, i prefere INI files, but i want do same
things with XML file format..

before i can save/read some element of INI files without the need to
parse or read all the file.. juste like getxxxxINI("Section", "Key")
and it return a string...
same for writing..without need to rewrite all the file..

is it possible to do same things with XML and all XML class in VB.NET
??

do you have some links or samples ??

thank a lot.
Sep 27 '06 #1
8 1773

Eric bouxirot wrote:
hi there,

i never used XML beforre, i prefere INI files, but i want do same
things with XML file format..

before i can save/read some element of INI files without the need to
parse or read all the file.. juste like getxxxxINI("Section", "Key")
and it return a string...
same for writing..without need to rewrite all the file..

is it possible to do same things with XML and all XML class in VB.NET
??

do you have some links or samples ??

thank a lot.
You need to figure out XML Serialization. Once you do, you will never
go back to INI files. After serializing an XML, everything in it is
availble as a bunch or properties.

Sep 27 '06 #2

z...@construction-imaging.com wrote:
Eric bouxirot wrote:
hi there,

i never used XML beforre, i prefere INI files, but i want do same
things with XML file format..

before i can save/read some element of INI files without the need to
parse or read all the file.. juste like getxxxxINI("Section", "Key")
and it return a string...
same for writing..without need to rewrite all the file..

is it possible to do same things with XML and all XML class in VB.NET
??

do you have some links or samples ??

thank a lot.

You need to figure out XML Serialization. Once you do, you will never
go back to INI files. After serializing an XML, everything in it is
availble as a bunch or properties.
Er, that should be after DE-serializing an XML file, the entire
contents are in a bunch of properties.

The trick is setting up a class structure that mirrors the structure of
the XML file.

Sep 27 '06 #3
>
Er, that should be after DE-serializing an XML file, the entire
contents are in a bunch of properties.

The trick is setting up a class structure that mirrors the structure of
the XML file.
ok, i understand, but if in futur i need to enhance the stucture of
data, then i can't read anymore the settings....
is it right ?
then, how can i do ?

thanks
Sep 27 '06 #4

Eric bouxirot wrote:

Er, that should be after DE-serializing an XML file, the entire
contents are in a bunch of properties.

The trick is setting up a class structure that mirrors the structure of
the XML file.

ok, i understand, but if in futur i need to enhance the stucture of
data, then i can't read anymore the settings....
is it right ?
then, how can i do ?

thanks
English must be your second language as your question is a bit garbled.
But if I understand correctly, if you need to add more settings to the
XML file, you would just add the appropriate properties to the already
existing class structure. The first time the XML file is serialized,
the new properties would show up as new XML nodes.

Using XML for a settings file is mainly for fairly complex applications
settings. If your need is simple, the My.Settings facility in Visual
Studio is actually easier to use.

Sep 27 '06 #5

Eric bouxirot wrote:

Er, that should be after DE-serializing an XML file, the entire
contents are in a bunch of properties.

The trick is setting up a class structure that mirrors the structure of
the XML file.

ok, i understand, but if in futur i need to enhance the stucture of
data, then i can't read anymore the settings....
is it right ?
then, how can i do ?

thanks
English must be your second language as your question is a bit garbled.
But if I understand correctly, if you need to add more settings to the
XML file, you would just add the appropriate properties to the already
existing class structure. The first time the XML file is serialized,
the new properties would show up as new XML nodes.

Using XML for a settings file is mainly for fairly complex applications
settings. If your need is simple, the My.Settings facility in Visual
Studio is actually easier to use.

Sep 27 '06 #6
>
English must be your second language as your question is a bit garbled.
oh...my english is so bad ??
:)
But if I understand correctly, if you need to add more settings to the
XML file, you would just add the appropriate properties to the already
existing class structure. The first time the XML file is serialized,
the new properties would show up as new XML nodes.
it's ok. do you have any example ?
>
Using XML for a settings file is mainly for fairly complex applications
settings. If your need is simple, the My.Settings facility in Visual
Studio is actually easier to use.
i want to learn XML too... if i use XML now here for simple
application, then i learn how it work and i can use it in more complex
applications for other things later...

thanks
Sep 27 '06 #7
Hello Eric,

Check out System.Xml.XmlSerialization namespace.

-Boo
>English must be your second language as your question is a bit
garbled.
oh...my english is so bad ??
:)
>But if I understand correctly, if you need to add more settings to
the XML file, you would just add the appropriate properties to the
already existing class structure. The first time the XML file is
serialized, the new properties would show up as new XML nodes.
it's ok. do you have any example ?
>Using XML for a settings file is mainly for fairly complex
applications settings. If your need is simple, the My.Settings
facility in Visual Studio is actually easier to use.
i want to learn XML too... if i use XML now here for simple
application, then i learn how it work and i can use it in more complex
applications for other things later...

thanks

Sep 28 '06 #8
The problem with XML Serialization is just the case the Eric states, if he
needs to add properties later, then adds them to the class, then tries to
deserialize one that's serialized with differening properties, he's kind of
sol...

Learning the XML is, perhaps, a better solution to his current problem.
One of the things I often do is start with an template XML file to use in my
applications. Although, it's not that difficult to create one on the fly.
You might want to take a look at the XmlDocument class in the .NET Framework

Let's say you open a template xml file with an object of XmlDocument type

Dim xdoc As New XmlDocument

xdoc.load("somefile")
'Get the root of the document

dim root as XmlElement
root = xdoc.DocumentElement

'Add and element to an Element that already exists
Dim node As XmlNode = root.SelectSingleNode("SomeElementName")
If Not node Is Nothing Then
Dim NewNode As XmlNode = xdoc.CreateElement("ElementName")
' Add the new node to the node you searched for
node.AppendChild(NewNode)
End if

' Iterating nodes
Dim node as XmlNode = root.SelectSingleNode("nodename")

For Each n as XmlNode In node.ChildNodes
' do something with n
Next

' Save the changes after iterating
xdoc.save()

HTH
Steve
<za***@construction-imaging.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>
z...@construction-imaging.com wrote:
>Eric bouxirot wrote:
hi there,

i never used XML beforre, i prefere INI files, but i want do same
things with XML file format..

before i can save/read some element of INI files without the need to
parse or read all the file.. juste like getxxxxINI("Section", "Key")
and it return a string...
same for writing..without need to rewrite all the file..

is it possible to do same things with XML and all XML class in VB.NET
??

do you have some links or samples ??

thank a lot.

You need to figure out XML Serialization. Once you do, you will never
go back to INI files. After serializing an XML, everything in it is
availble as a bunch or properties.

Er, that should be after DE-serializing an XML file, the entire
contents are in a bunch of properties.

The trick is setting up a class structure that mirrors the structure of
the XML file.

Sep 28 '06 #9

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

Similar topics

5
by: Sam Carleton | last post by:
It is my understanding that in .Net the registry is not the prefered place to save application settings. What has Microsoft put in place to replace it? I thought it was the .config file, but I...
1
by: DraguVaso | last post by:
Hi, I found some examples for storing the FormSettings of a Form in an XML-file, but none of these could match my criteria: What I am looking for is the possibility to save the FormSettings of...
3
by: Boris Sargos | last post by:
Hi, I don't maange to save the user settings in my application. I created a settings file named MySettings.settings, that contains the property "BackupFolder" (string typed), in User mode. The...
3
by: Stefano | last post by:
I've a form windows with a lot of textbox controls. How can I do if I have to save all text proprety of this controls in an external file, to reload them in future?
4
by: keithb | last post by:
How can an application change settings in the web.config file? I need to allow users to configure SMTP email settings with functionality similar to that provided developers by the ASP.NET Web Site...
0
by: ssg31415926 | last post by:
I've been trying to save a hashtable in an Application Settings file. I need to save settings for each tabPage on a form. Trouble is, the number of tabPages is determined at runtime, so I can't...
2
by: John | last post by:
I have a Win app in C#. I want to save the data the user enterere into textboxes and the selections the user made to comboboxes when the user close the app. So next time when the user launches the...
4
by: Richard Lewis Haggard | last post by:
I have an application that can't use the registry to save various user options and application settings. My first thought was to simply use an application configuration file but this approach seems...
0
by: =?Utf-8?B?Qy4gSHVnaGVz?= | last post by:
Hello, I have a .net 2.0 application using a 'Settings.settings' configuration file to store application settings. The settings are modified at runtime and stored when the user exits the...
3
by: evenlater | last post by:
I have an Access application on a terminal server. Sometimes my users need to export reports to pdf, rtf or xls files and save them to their own client device hard drives. They can do that right...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
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...

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.