473,699 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.DOMDocume nt
Dim root As IXMLDOMElement

Set objDOMDocument = New DOMDocument
objDOMDocument. async = False
objDOMDocument. Load "c:\temp\500001 7.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 17680
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.DOMDocum ent40
3/ best way on msxml is using

set theNode = objDOMDocument. selectSingleNod e(strXpath)
for one (first matching) node
or
set theNodeSet = objDOMDocument. selectNodes(str Xpath)
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********@man ulife.com> wrote in message
news:38******** *************** ***@posting.goo gle.com...
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.DOMDocume nt
Dim root As IXMLDOMElement

Set objDOMDocument = New DOMDocument
objDOMDocument. async = False
objDOMDocument. Load "c:\temp\500001 7.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. selectSingleNod e(strXpath)
for one (first matching) node
or
set theNodeSet = objDOMDocument. selectNodes(str Xpath)
selectNodes for a node set (multiple matches)


dont forget

objDOMDocument. setProperty "SelectionLangu age", "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
12207
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 written to a single interface, but support many different manufacturers' barcode scanning devices. I do not want to be tied to one manufacturers' software interfaces. - Must support use of the scanner from Visual Basic, and ideally from C/C++ and...
3
6958
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, any comments/suggestions would be greatly appreciated.
33
3150
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 differences. Ok, Visual Studio has C++, VB and J++ thrown in plus some extra bells and whistles (I already have some minimal experience) but are both IDE's essentially the same (including the same IDE support for creating forms, ADO.NET DataSets,...
5
7231
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 error) Save your work and restart Visual Studio .NET." has anyone seen this bug and can you confirm one way or the other whether or not it can corrupt your source files? (by 'corrupt' i mean: do anything to it that will cause it to fail to load and...
2
1598
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 msdn I found out that there is a kind of project that you need to create in order to be able to make custom controls and it's called "Windows Control Library project".
5
13991
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 like to get one of these books. However I have a small problem. I have found two books in the Sams Teach Yourself... range. The problem is that one book is "Teach Yourself the C# Language in 21
5
1252
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 Excel (user forms, etc.), and I've written a lot of different languages. On the other hand, I never have gotten the hang of Visual C++. Being able to interact with the internet is a secondary consideration. Thanks in advance for any...
97
5496
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 the first place. Anyone else heard about this development? The Master
6
1379
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 the last six months, and they're using Java more than any other development language, according to a recently published survey."
8
1919
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 somebody tell me, what's the real difference between the Pro and Std Editions of Visual Studio (besides the hefty price difference)? I can almost afford the Std edition, but will I be sorry for not saving up and buying the Pro? Thanks! Mark
0
8686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8911
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6533
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.