|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
XML to save some settingshi 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. Eric bouxirot wrote:
Show quoteHide quote > hi there, You need to figure out XML Serialization. Once you do, you will never> > 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. go back to INI files. After serializing an XML, everything in it is availble as a bunch or properties. z***@construction-imaging.com wrote:
Show quoteHide quote > Eric bouxirot wrote: Er, that should be after DE-serializing an XML file, the entire> > 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. 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 > 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. data, then i can't read anymore the settings.... is it right ? then, how can i do ? thanks Eric bouxirot wrote:
> > English must be your second language as your question is a bit garbled.> > 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 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. Eric bouxirot wrote:
> > English must be your second language as your question is a bit garbled.> > 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 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. > oh...my english is so bad ??> English must be your second language as your question is a bit garbled. :) it's ok. do you have any example ?> 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. > i want to learn XML too... if i use XML now here for simple > 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. application, then i learn how it work and i can use it in more complex applications for other things later... thanks Hello Eric,
Check out System.Xml.XmlSerialization namespace. -Boo Show quoteHide quote >> 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 > 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.com> wrote in message Show quoteHide quote news:1159366968.912200.57800@b28g2000cwb.googlegroups.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. >
overflow detection without try-catch
How can I create a Shortcut (with parameters) on a user-desktop with vb.net? how to run the execuatable before windows shutting down Redirecting standard output Posting login data with HttpWebRequest Permanent Rectangle on Form. VB Program - CHM help integration Getting nodes from an XML-document Q: select (case insensitive) Button with dropdown style like on a toolbar |
|||||||||||||||||||||||