XML Help wanted

E

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.
 
C

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

XML Help 7
XML LINQ - output to XMLtextwriter - the headaches... 2
Edit XML File 1
Having a database issue 0
XML DTDs Versus XML Schema 0
xml woes 1
XML 2
Processing XML With C# and .NET 0

Top