Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

XML in ViBa with DOM

Posted on 2003-02-27
4
Medium Priority
?
218 Views
Last Modified: 2010-05-01
Using Visual Basic together with Ms Xml 4.0 SP1

with the following xml-file:

<?xml version="1.0" ?>
<!DOCTYPE data SYSTEM "-------Censored--------">
<data>
<error code="-3002804">
<string>WARNING: vault..proc_insertMSG. Message cannot be queued. Transmission is within 60 seconds of existing entry in queue.</string>
</error>
</data>

Now, i'm looking for ways to read the <string> , but strangely it works no matter what i try, but i can't read the error code itself

VB code i have sofar:

Dim doc As New DOMDocument40
doc.async = False
doc.validateOnParse = False
doc.resolveExternals = False
xmlPath = "temp.xml"
doc.Load xmlPath
message = doc.selectSingleNode("data").Text  '<-- still gives the whole line :S
0
Comment
Question by:LaMoS
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8035684
learning...
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 8036235
Change this line:
message = doc.selectSingleNode("data").Text

To:
message = doc.selectSingleNode("data/error/string").Text

Anthony
0
 

Expert Comment

by:WHalphen
ID: 8038850
It's not clear whether you want the string or the error code.  If you want the string, then acperkins' suggestion should work.  If you want the error code you need to use:
oNode=doc.selectSingleNode("data/error")
If Not oNode Is Nothing then
  message=oNode.Attributes.getNamedItem("default").nodeValue
End If
0
 

Accepted Solution

by:
WHalphen earned 300 total points
ID: 8038856
Sorry,

I had a typo... change "default" to "code"...

oNode=doc.selectSingleNode("data/error")
If Not oNode Is Nothing then
 message=oNode.Attributes.getNamedItem("code").nodeValue
End If
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

580 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