reading xml

irade92

Registered User.
Local time
Today, 19:39
Joined
Dec 26, 2010
Messages
229
I am trying to put in a variable from xmlnode.element ( facsimile) value '777777'

<hospital>
<specialist1>
<id>815175007</id>
<medic>
<facsimile>777777</facsimile>
<first_name>Bob</first_name>
<last_name>Smith</last_name>
</medic>
</specialist1>
</hospital>
I am using this code:

Set xmlNodeList = resp.getElementsByTagName("*")
For Each xmlNode In xmlNodeList
If xmlNode.nodeName = "specialist1" Then
Dim spec1 As String

If xmlNode.HasChildNodes = True Then
If xmlNode.ChildNodes.item(1).nodeName = "medic" Then
If xmlNode.HasChildNodes = True Then
spec1 = xmlNode.ChildNodes.item(0).text
End If
End If
End If
Next
but it doesn't work
Please help
 
Hmm, would it be easier to use an XPath instead? For example:
Code:
Set xmlNode=resp.SelectSingleNode("/hospital/medic/facsimile")
(untested - just a guess)
 
Hmm, would it be easier to use an XPath instead? For example:
Code:
Set xmlNode=resp.SelectSingleNode("/hospital/medic/facsimile")
(untested - just a guess)

and then how to put the value in the variable?
 
and then how to put the value in the variable?
Maybe something like?
Code:
varname = xmlNode.nodeValue
If that doesn't work, you could try:
Code:
varname = xmlNode.childNodes(0).nodeValue
 
Maybe something like?
Code:
varname = xmlNode.nodeValue
If that doesn't work, you could try:
Code:
varname = xmlNode.childNodes(0).nodeValue

Thanks a lot ...very nice idea..
 

Users who are viewing this thread

Back
Top Bottom