0

a small dummy question, sorry for that, I didn't found any reference about it. How can I know whats is the options i got for variable 'el', i mean which method can i active on 'el' for example I know I can use method "getAttribute("....")", but what else which else method or property i can use ?

note: Ctrl + space won't work in this case. i found this link but it's not relevant for vba https://msdn.microsoft.com/en-us/library/ms757828(v=vs.85).aspx

VBA:

Dim oDoc As New MSXML2.DOMDocument30
Dim el As Object
Dim XML As String

XML =("C:\........")

oDoc.validateOnParse = True
oDoc.Load XML  


dim Name as String
Name= "yaron"


  'select the User node with Name="Yaron"
    Set el = oDoc.SelectSingleNode("/GetUserInfo/User[@Name='" & Name & "']")

'e. ???????whats my options?
    If Not el Is Nothing Then
    Debug.Print el.getAttribute("LoginName")
Else
    Debug.Print "user id not found!"
End If

XML:

  <GetUserInfo>
           <User ID="16" Name="DAVID" LoginName="login1"/>
           <User ID="17" Name="GAL" LoginName="login2"/>
           <User ID="18" Name="YARON" LoginName="login3"/>
  </GetUserInfo>
David
  • 169
  • 4
  • 16
  • I'm not sure what you're asking but if the question is how can you get intellisense to show methods and properties of `el` then declare `el` explicitly as a node type (rather than an object). – Ambie Dec 19 '16 at 14:53
  • 2
    [loop through the children of the `GetUserInfo` node](http://stackoverflow.com/questions/20020990/looping-through-xml-using-vba) – Scott Holtzman Dec 19 '16 at 14:54
  • @Ambie after declare el explicitly as a node type: "Dim el As node" i still can't see which method will work for el .. :/ – David Dec 19 '16 at 15:40
  • Have a look at the answer from @TimWilliams. If you follow his declaration, then intellisense will work. – Ambie Dec 19 '16 at 23:42

1 Answers1

2

A node can refer to different types of node objects, and these do not share a single set of properties/methods.

Try being more explicit in your variable type declaration, such as

Dim el As IXMLDOMElement 

(check @ScottHoltzman's link)

Tim Williams
  • 154,628
  • 8
  • 97
  • 125