Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple method (function) to read an XML file ?

Status
Not open for further replies.

dimsis

Programmer
Aug 6, 2000
76
0
0
GR
Is there any simple function (no class, dll's etc) to read an XML file ?
I want to read a Pad file (Sample XML file:

I need to read all the XML data and then write it into my database. (i know how to do this, i only need a fast function to read the specified values from the xml tags)
 
Why the anti-object stance?

The MS XML DOM gives offers some very good clases for approaching this task. If you're not considering it because you're afraid of classes themselves, then my honest advice as a professional would be "Get Over It".

Many people have trouble with classes/objects, but they are well worth the headache of reading up on.

mmilan.

 
dimsis
You *can* use ordinary file I/O to read an XML file, however you will be shooting yourself in the foot if you do so. There is *much* more to XML than just a file with some tags surrounding the data.

My advice would be to use the MSXML 4.0 object library, and use the .Load method on the DomDocument40 object. This will load a reasonably-sized XML document in memory, after which you can use XPath queries to retrieve the values you need.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
If i use MSXML 4.0 i must included in the distribution package (setup). I'm already using ADO, scripting runtime, common dialog, tabbed dialog and common controls...
I don't want to endorse even more the users and force them to download and install MSXML 4.0.
Does anyone has another solution? without extra components, references, libraries, classes etc?
 
Well, I wish you luck. I, for one, have no interest in reinventing the wheel in this specialist area.
 
I've never understand what's the meaning of comments like strongm's.
If you have something to suggest please do, but try not to critisize and offend others, please.
Anyone ?
 
If all your users have Internet Explorer 4 or later installed they will already have all the XML Objects on their PCs although they won't necessarily be version 4.0.

However if you stick to using the generic class names e.g. DOMDocument not DOMDocument40 you will be OK. For the type of job you wish to do the functionality has not changed since version 2.

Users will also have the Scripting Runtime (includes FileSystemObject) installed along with IE.

Most of the other components you mention are also installed by default with the exception of some specific VB6 components.

Try producing a package that doesn't include these additional components and see if it works in a typical user environment before going to the trouble of adding them to your package.
 
Thanx bbofin,

i've found MSXML 3.0 at the references when i made some tests, but i was 'nt sure if i've installed this, or if it was installed by the IE 6.0 i've got in my system.
Also thanx for the other infos, that what's i was thinking to do. I'm gonna give only the files (not even package it) to some XP / IE 5.5 > users to check if it's working correctly.
So i'm gonna try some MSXML v.3.0 load document commands and see if it can solve my problems.

Thank you all your help,
Dimitris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top