I'm having problems to get the values from the tags with no node value, for example:
<itemdata name="someName" />
It seems I can't get the nodeName in this situation. How should I retrieve the attributes values of these tags?
Printable View
I'm having problems to get the values from the tags with no node value, for example:
<itemdata name="someName" />
It seems I can't get the nodeName in this situation. How should I retrieve the attributes values of these tags?
How about this?Code:Option Explicit
Private Sub Form_Load()
'usage
Debug.Print extractTagValue("<itemdata name=""someName""/>", "itemdata name")
End Sub
Private Function extractTagValue(strString As String, strTag As String)
Dim lngStart As Long
Dim lngEnd As Long
lngStart = InStr(1, strString, "<" & strTag & "=")
If lngStart Then
lngStart = (lngStart + Len(strTag) + 2)
lngEnd = InStr(lngStart, strString, Chr(34))
lngEnd = InStr(lngEnd + 1, strString, Chr(34))
If lngEnd Then
extractTagValue = Mid(strString, (lngStart + 1), (lngEnd - lngStart - 1))
End If
End If
End Function
Uhm... I guess I should have especified I'm using MSXML 4.0.
Nevermind... I was forcing the selection of text nodes, and this sort of nodes are just element types.