Results 1 to 4 of 4

Thread: [RESOLVED] How to get some node elements in a XML document

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    Resolved [RESOLVED] How to get some node elements in a XML document

    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?

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: How to get some node elements in a XML document

    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    Re: How to get some node elements in a XML document

    Uhm... I guess I should have especified I'm using MSXML 4.0.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    Re: How to get some node elements in a XML document

    Nevermind... I was forcing the selection of text nodes, and this sort of nodes are just element types.

Posting Permissions

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



Click Here to Expand Forum to Full Width