Home All Groups Group Topic Archive Search About
Author
26 May 2009 12:52 PM
Ueli Werner
Hi there

I like to store an read data into an xml-file.

The data which is used is a very simle List of persons:

Name, surename
name2, surname2
....
....

I don't want to use a db, so I decided to create XML.

But I don't know how to create a simple XML and read from this XML.

Any help?

Thanks alot

Ueli Werner

Author
26 May 2009 2:51 PM
MikeD
Show quote Hide quote
"Ueli Werner" <u***@hotmail.com> wrote in message news:B65D37CF-CBE0-4C32-85F0-792CAD205BA6@microsoft.com...
> Hi there
>
> I like to store an read data into an xml-file.
>
> The data which is used is a very simle List of persons:
>
> Name, surename
> name2, surname2
> ...
> ...
>
> I don't want to use a db, so I decided to create XML.
>
> But I don't know how to create a simple XML and read from this XML.
>
> Any help?
>


One way would be to use the Microsoft XML Core Services.  This is an ActiveX component.  There are several versions of it.  v3.0 is
included with Win2000 SP4 and later. v6.0 is the latest and is included with Vista and later, but may not exist on systems running
XP/Server2003 or earlier. There is, however, a redistributable package you can install.

Here's a link that describes the versions in more detail and has links to documentation:
http://msdn.microsoft.com/en-us/xml/bb291077.aspx

Also, since XML files are just text files, you could simply use VB's own file I/O for everything.  Of course, you'd need to know a
few specifics about the XML format.

--
Mike
Author
27 May 2009 4:57 AM
Bob Riemersma
"Ueli Werner" <u***@hotmail.com> wrote in message
news:B65D37CF-CBE0-4C32-85F0-792CAD205BA6@microsoft.com...
> Hi there
>
> I like to store an read data into an xml-file.
>
> The data which is used is a very simle List of persons:
>
> Name, surename
> name2, surname2
> ...
> ...

For simple tabular data like this there are lots of options.  One of the
simplest in VB is to just use the regular Write#/Input# statements.

These process CSV files in a special VB format that handles Date, Boolean,
String, and various numeric types in a locale-neutral manner.  The only
caveat I have found is that for String values " characters are not
automatically escaped.  If you use Write# with a String value like:

strVar = "Tom said ""Get lost!"""
Write #intFile, strVar

You'll have trouble reading it back because the file will contain:

"Tom said "Get lost!""

One workaround might be to escape String quotes yourself, as in:

strVar = "Tom said ""Get lost!"""
Write #intFileOut, Replace$(strVar, """", vbTab)
:
:
Input #intFileIn, strVar
strVar = Replace$(strVar, vbTab, """")

Aside from that minor glitch though this is a pretty simple way to deal with
tabular data, and with a lot less overhead than any form of XML processing.
Using vbTab is just one possibility and you could use vbFormFeed or any
other character or substring you know will not occur in your String values
as a " placeholder.
Author
27 May 2009 5:50 PM
Jeff Johnson
"Bob Riemersma" <nospam@nil.net> wrote in message
news:%23MIoYeo3JHA.4960@TK2MSFTNGP04.phx.gbl...

> For simple tabular data like this there are lots of options.  One of the
> simplest in VB is to just use the regular Write#/Input# statements.

Write #? As far as I'm concerned, Write # is NEVER an option. Print #, yes.