Find XML node with vba userform
Results 1 to 3 of 3

Thread: Find XML node with vba userform
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Nov 2011
    Posts
    100
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Find XML node with vba userform

    Hi Guys,

    Im hoping someone can help me with this.

    Im trying to find a xml node,
    I can find the node, however, I need to look for the node from whats entered in a userform textbox.

    Here is the code Im using:
    Code:
    Private sub commandbutton1_click()
    Dim xmlObj As Object
    Dim singlenode As Object
    Dim test1 As String
    
    Set xmlObj = CreateObject(msxlm2.domdocument)
    XmlObj.async = False
    XmlObj.valdateOnParse = False
    XmlObj.Load (c:/myfolder/test.xml)
    
    Test1 = me.txtbox1.value
    
    Set singlenode = XmlObj.SelectSingleNode(//ContactInfo[EmpID=Test1]
    
    Debug.print singlenode.xml
    
    End sub
    If I change test1 to an actual employee Id, it works.
    Is there anyway to get this to work with the userform box please? Have I missed something?

  2. #2
    MrExcel MVP
    Join Date
    Mar 2004
    Location
    Canada
    Posts
    18,799
    Post Thanks / Like
    Mentioned
    35 Post(s)
    Tagged
    5 Thread(s)

    Default Re: Find XML node with vba userform

    Try...

    Code:
    Set singlenode = XmlObj.SelectSingleNode("//ContactInfo[EmpID=" & Test1 & "]")
    Hope this helps!

  3. #3
    Board Regular
    Join Date
    Nov 2011
    Posts
    100
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Find XML node with vba userform

    Hi Domenic,

    Thanks for that 🙂
    Problem solved, thanks

    Zod

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •