Home All Groups Group Topic Archive Search About
Author
8 Mar 2006 9:50 PM
edamron
I'm new to vb.net and have never used xml.  However, xml looks pretty
straight forward and I would like to learn how use it to create a
configuration file for a small app.

I got the xmlTextWriter to write out a file and I thought "Oh!  this
must be the way!"  But now I'm backing off from it because even though
it wrote a file I'm not sure that the file is correct xml and there are
many classes that seem to work with xml files and I may not be using
the best choice.

So I would like to ask which class would be the best to use to create
what I want?  Also a small code snippet showing me how to use the
class(es) would help.

Let's say I have two configuration elements I want to store and
retrieve:

DirectoryPath and DatabaseName

And the values were "C:\mypath" and "myDatabase"

Thanks in advance.

Author
9 Mar 2006 6:21 AM
Cor Ligthert [MVP]
deamron,

As there is one thing not straight foreward than it is XML, the
documentation that describes it seems to be more than a meter high. It is a
way to transport data where the description of that is given.

An easy way to use it is as the dataset.
Simple made typed here.

dim ds as new dataset
dim dt as new datatable
ds.add(dt)
dt.columns.add("myItem1")
dt.columns.add("myItem2")
dt.loaddatarow(new Object() {"deamron", "cor"}, true)

To write it
ds.writexml(mypath)
To read it than again
ds.readxml(mypath)

There are more methods to add a row by the way.

I hpe this helps,

Cor

Show quoteHide quote
"edamron" <edamron@spamcop.net> schreef in bericht
news:1141854612.270147.87730@p10g2000cwp.googlegroups.com...
> I'm new to vb.net and have never used xml.  However, xml looks pretty
> straight forward and I would like to learn how use it to create a
> configuration file for a small app.
>
> I got the xmlTextWriter to write out a file and I thought "Oh!  this
> must be the way!"  But now I'm backing off from it because even though
> it wrote a file I'm not sure that the file is correct xml and there are
> many classes that seem to work with xml files and I may not be using
> the best choice.
>
> So I would like to ask which class would be the best to use to create
> what I want?  Also a small code snippet showing me how to use the
> class(es) would help.
>
> Let's say I have two configuration elements I want to store and
> retrieve:
>
> DirectoryPath and DatabaseName
>
> And the values were "C:\mypath" and "myDatabase"
>
> Thanks in advance.
>