?
Solved

XML in ViBa with DOM

Posted on 2003-02-27
4
Medium Priority
?
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 7 hours left to enroll

801 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