Flying-Kiwi
asked on
What are the most common XML read/write operations?
Hi,
I've been using 'flat' text files as data files. I'm considering changing to XML data files. I've had a look at some XML info on the Net and there seems to be a lot more than one way to 'skin the cat'.
So, I'd like to ask what the most common ways are to read, write and do any other useful stuff are.
* Efficiency is irrelevant due to the small size of the files I'm using.
* I'm using VB.NET Express Edition, if that makes any difference.
Here's the simplest case that I'll be working with:
************************** ********** *********
[TIME]
TimeEstimated: 5.25 TimeEarliest: 4.25 TimeLatest: 6.0 Intel: 2
[WEATHER]
TypeEstimated: 3 TypeBest: 1 TypeWorst: 4 HeightEstimated: 7 HeightLowest: 5 HeightHighest: 15 Intel: 3
************************** ********** *********
I figure that as an XML file it might end up like this (fow stands for Fog Of War, the name of the - randomisation - utility, and the also the name of the main parameters data file):
************************** ********** *********
<?xml version="1.0" ?>
- <fow>
- <time>
<timeEstimated>5.25</timeE stimated>
<timeEarliest>4.25</timeEa rliest>
<timeLatest>6.0</timeLates t>
<timeIntel>2</timeIntel>
</time>
- <weather>
<typeEstimated>3</typeEsti mated>
<typeBest>1</typeBest>
<typeWorst>4</typeWorst>
<heightEstimated>7</height Estimated>
<heightLowest>5</heightLow est>
<heightHighest>15</heightH ighest>
<weatherIntel>3</weatherIn tel>
</weather>
</fow>
************************** ********** *********
* Are Attributes often used in the 'real world'? I read on W3C.com that it may be preferable (at least in theory) to only use attributes for ID tags.
* Is there an 'XML editor' that will put in closing tags as you go, when making an XML file by hand (for example for testing).
* I understand that an XML schema is a must-do. Is there a control in VB.NET Express (or elsewhere) that makes this easier (e.g. via a Wizard)?
This is a new area for me, so your help is especially appreciated. :--)
I've been using 'flat' text files as data files. I'm considering changing to XML data files. I've had a look at some XML info on the Net and there seems to be a lot more than one way to 'skin the cat'.
So, I'd like to ask what the most common ways are to read, write and do any other useful stuff are.
* Efficiency is irrelevant due to the small size of the files I'm using.
* I'm using VB.NET Express Edition, if that makes any difference.
Here's the simplest case that I'll be working with:
**************************
[TIME]
TimeEstimated: 5.25 TimeEarliest: 4.25 TimeLatest: 6.0 Intel: 2
[WEATHER]
TypeEstimated: 3 TypeBest: 1 TypeWorst: 4 HeightEstimated: 7 HeightLowest: 5 HeightHighest: 15 Intel: 3
**************************
I figure that as an XML file it might end up like this (fow stands for Fog Of War, the name of the - randomisation - utility, and the also the name of the main parameters data file):
**************************
<?xml version="1.0" ?>
- <fow>
- <time>
<timeEstimated>5.25</timeE
<timeEarliest>4.25</timeEa
<timeLatest>6.0</timeLates
<timeIntel>2</timeIntel>
</time>
- <weather>
<typeEstimated>3</typeEsti
<typeBest>1</typeBest>
<typeWorst>4</typeWorst>
<heightEstimated>7</height
<heightLowest>5</heightLow
<heightHighest>15</heightH
<weatherIntel>3</weatherIn
</weather>
</fow>
**************************
* Are Attributes often used in the 'real world'? I read on W3C.com that it may be preferable (at least in theory) to only use attributes for ID tags.
* Is there an 'XML editor' that will put in closing tags as you go, when making an XML file by hand (for example for testing).
* I understand that an XML schema is a must-do. Is there a control in VB.NET Express (or elsewhere) that makes this easier (e.g. via a Wizard)?
This is a new area for me, so your help is especially appreciated. :--)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thx for giving the example. I'm still trying to work out the best XML classes and associated code to use.
Example:
Dim doc As New XmlDocument
doc.Load("c:\temp\test.xml ")
Dim node As XmlNode = doc.SelectSingleNode("//ti me")
Bob
Dim doc As New XmlDocument
doc.Load("c:\temp\test.xml
Dim node As XmlNode = doc.SelectSingleNode("//ti
Bob
ASKER
Okay, so using attributes would be okay. Thx for laying out the example XML.
May I ask what the 'normal' code is for reading and writing XML files in VB.NET?