1

I have a little VB script that works while using MSXML 3.0 but not 6.0. I have read that I should stay away from both 4.0 & 5.0.

All the script does is find a node, display the inner text in a message box.

Test script:

Dim xmlResponseDocument

' Set xmlResponseDocument = CreateObject("Msxml2.DOMDocument.3.0")    ' uses MSXML 3.0
Set xmlResponseDocument = CreateObject("Msxml2.DOMDocument.6.0")    ' uses MSXML 6.0

' Load the xml document from a file for testing
xmlResponseDocument.load("C:\Trash\IsFollowupNurseValid.xml")

Dim Nodes
set Nodes=xmlResponseDocument.getElementsByTagName("IsFollowupNurseValidResult")

for each child in Nodes
    MsgBox child.text, ,child.nodeName                                
next

For Each lookupTypeNode In xmlResponseDocument.SelectNodes("//IsFollowupNurseValidResult")
    MsgBox lookupTypeNode.Text, , "Select Nodes"
Next

MsgBox "Finish Running"

Set Nodes=nothing   
set xmlResponseDocument = nothing

XML Document:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <IsFollowupNurseValidResponse xmlns="http://example.com/Quark/">
            <IsFollowupNurseValidResult>false</IsFollowupNurseValidResult>
        </IsFollowupNurseValidResponse>
    </s:Body>
</s:Envelope>
Black Frog
  • 11,595
  • 1
  • 35
  • 66
  • By [MSDN: Building MSXML Applications](https://msdn.microsoft.com/en-us/library/ms753804(v=vs.85).aspx), some of the MSXML 3.0 examples will not work with MSXML 6.0 for some reasons... (This topic provides instructions on making MSXML 3.0 samples work with MSXML 6.0) – JosefZ Apr 23 '15 at 21:45
  • This issue seems to be with namespaces but I cannot quite nail it. If you remove the name spaces then 3 and 6 are the same. If you add a pre fix to the inner xml they also both work e.g. getElementsByTagName("t:IsFollowupNurseValidResult"). Remove the namespace declaration on the inner xml and it works as well – Paxic Apr 24 '15 at 00:35

0 Answers0