473,378 Members | 1,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Visual Basic 6.0 Code - Reading XML

Hi there, I'm trying out the following code in order to read in an XML
document.

Private Sub GetXML_Click()
Dim objDOMDocument As MSXML.DOMDocument
Dim root As IXMLDOMElement

Set objDOMDocument = New DOMDocument
objDOMDocument.async = False
objDOMDocument.Load "c:\temp\5000017.XML"
Set root = objDOMDocument.documentElement

For Each child In root.childnodes
MsgBox child.Text
Next
End Sub

....but, I'm getting a compile error on the first line, indicating that
it can't find the library. I'm sure it's something obvious, but I'm
not sure exactly where to go next. Can anyone offer some assistance??

Once I've gotten the XML loaded, I also need to parse the nodes and
find a specific id/name within the document. Any suggestions on how
to best achieve this????

Mucho Gracias!!!

Dan
Jul 20 '05 #1
2 17663
1/ Have you added a refererence to the Microsoft MSXML component (and has it
been installed on your machine)?
2/ Are you using the latest version (MSXML 4) if so use MSXML2.DOMDocument40
3/ best way on msxml is using

set theNode = objDOMDocument.selectSingleNode(strXpath)
for one (first matching) node
or
set theNodeSet = objDOMDocument.selectNodes(strXpath)
selectNodes for a node set (multiple matches)

strXPath is an Xpath expression describing the path to the node to be
selected

e.g.

"/root/items/item[(@id='F1') and (name='Fred')]"

If the ID is defined as a dataitem of type ID (in a DTD) then you can use
the xpath id function

"id('F1')"

Colin

"Dan G." <da********@manulife.com> wrote in message
news:38**************************@posting.google.c om...
Hi there, I'm trying out the following code in order to read in an XML
document.

Private Sub GetXML_Click()
Dim objDOMDocument As MSXML.DOMDocument
Dim root As IXMLDOMElement

Set objDOMDocument = New DOMDocument
objDOMDocument.async = False
objDOMDocument.Load "c:\temp\5000017.XML"
Set root = objDOMDocument.documentElement

For Each child In root.childnodes
MsgBox child.Text
Next
End Sub

...but, I'm getting a compile error on the first line, indicating that
it can't find the library. I'm sure it's something obvious, but I'm
not sure exactly where to go next. Can anyone offer some assistance??

Once I've gotten the XML loaded, I also need to parse the nodes and
find a specific id/name within the document. Any suggestions on how
to best achieve this????

Mucho Gracias!!!

Dan

Jul 20 '05 #2
set theNode = objDOMDocument.selectSingleNode(strXpath)
for one (first matching) node
or
set theNodeSet = objDOMDocument.selectNodes(strXpath)
selectNodes for a node set (multiple matches)


dont forget

objDOMDocument.setProperty "SelectionLanguage", "XPath"

to use XPath instead of MS pattern language
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: CHANGE username to westes | last post by:
What are the most popular, and well supported, libraries of drivers for bar code scanners that include a Visual Basic and C/C++ API? My requirements are: - Must allow an application to be...
3
by: pix | last post by:
Hello, I would like to start learning Visual Basic, and I was wondering if there are any recomendations to any ebooks, or actual books for that matter. I have my eye on this book by John Smiley,...
33
by: John Timbers | last post by:
I'd like to purchase Visual C# .Net for learning purposes only since it's a lot cheaper than Visual Studio (note that I'm a very experienced C++ developer). Can someone simply clarify the basic...
5
by: K. Shier | last post by:
when attempting to edit code in a class file, i see the bug "Visual Basic ..NET compiler is unable to recover from the following error: System Error &Hc0000005&(Visual Basic internal compiler...
2
by: SL33PY | last post by:
Hi, I'm currently working on an application written in Visual Basic .NET. I want to create some User Controls in order to add some specific functionality to the application. While reading on...
5
by: Ditoa | last post by:
Hi all, I would like to learn how to program in C# and have been looking at some books to help me get started. As I have found the Sams Teach Yourself... books very good in the past I would...
5
by: JimS | last post by:
I just got myself a Visual Basic.Net compiler, and I'm looking for books to help me learn. Specifically, I'm a very experienced programmer (going back to 1968), I'm pretty accomplished in VBA for...
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
6
by: John Bailo | last post by:
http://www.informationweek.com/software/showArticle.jhtml?articleID=196600515 Developers Embrace Java, Drop Visual Basic "Developers have abandoned Microsoft's Visual Basic in droves during...
8
by: Mark | last post by:
I recently picked up some reading materials on Visual Basic 2005 and although I don't actually own Visual Studio, I'm considering buying it - just to try to teach myself some VB. Anyway, can...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.