What are the most common XML read/write operations?

Posted on 2006-05-12
Last Modified: 2013-11-19

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:

TimeEstimated: 5.25 TimeEarliest: 4.25 TimeLatest: 6.0 Intel: 2

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>
- <weather>


* Are Attributes often used in the 'real world'? I read on 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.  :--)
Question by:Flying-Kiwi
    LVL 96

    Accepted Solution

    1) Does VB.NET Express have an "Add New Item" type of XML document?  If so, then you should have an XML editor.  I have the Professional edition, which has the XML editor.

    2) This is one way that you could do the XML:

    <?xml version="1.0" encoding="utf-8" ?>
      <time estimated="5.25" earliest="4.25" latest="6.0" intel="2" />
        <type estimated="3" best="1" worst="4" />
        <height estimated="7" lowest="5" highest="15" />


    Author Comment

    Unfortunately there's no XML editor on VB.NET Express.

    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?

    Author Comment

    Thx for giving the example. I'm still trying to work out the best XML classes and associated code to use.
    LVL 96

    Expert Comment

    by:Bob Learned

    Dim doc As New XmlDocument

    Dim node As XmlNode = doc.SelectSingleNode("//time")


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Specialist

    HTML5 development skills are critical to all developers. HTML5 is the foundation to almost any development process. That's why business, design studios, development shops and other organizations need HTML5 developers. Get your foot in the door as a HTML5 specialist.

    Suggested Solutions

    Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa‚Ķ
    Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now