472,333 Members | 1,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,333 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 17618
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...
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...
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++...
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...
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...
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...
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...
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...
6
by: John Bailo | last post by:
http://www.informationweek.com/software/showArticle.jhtml?articleID=196600515 Developers Embrace Java, Drop Visual Basic "Developers have...
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.