• 쇼핑몰
  • 커뮤니티
  • 북마크

vb6.0/vba




[vb6.0/vba] [vb6.0/vba] Web Browser(Internet Explorer) html Document xPath

하나를하더라도최선을
2020.09.29 08:37 81 1

본문



Public Function getXPathElement(sXPath As String, objElement As ObjectAs Object
    On Error GoTo ErrPass
    Dim sXPathArray() As String
    Dim sNodeName As String, sNodeNameIndex As String
    Dim sRestOfXPath As String
    Dim lNodeIndex As Long, lCount As Long
    sXPathArray = Split(sXPath, "/")
    sNodeNameIndex = sXPathArray(1)
    If Not InStr(sNodeNameIndex, "["> 0 Then
        sNodeName = sNodeNameIndex
        lNodeIndex = 1
    Else
        sXPathArray = Split(sNodeNameIndex, "[")
        sNodeName = sXPathArray(0)
        lNodeIndex = CLng(Left(sXPathArray(1), Len(sXPathArray(1)) - 1))
    End If
    sRestOfXPath = Right(sXPath, Len(sXPath) - (Len(sNodeNameIndex) + 1))
    Set getXPathElement = Nothing
    For lCount = 0 To objElement.ChildNodes().Length - 1
        If UCase(objElement.ChildNodes().Item(lCount).nodeName) = UCase(sNodeName) Then
            If lNodeIndex = 1 Then
                If sRestOfXPath = "" Then
                    Set getXPathElement = objElement.ChildNodes().Item(lCount)
                Else
                    Set getXPathElement = getXPathElement(sRestOfXPath, objElement.ChildNodes().Item(lCount))
                End If
            End If
            lNodeIndex = lNodeIndex - 1
        End If
    Next lCount
ErrPass:
End Function






댓글목록 1

하나를하더라도최선을님의 댓글

하나를하더라도최선을 2020.09.29 08:42

요소의 값들을 가져오는 방법!!
검증안됨 추후 필요시 검증 후 사용


HTML.getElementById("popup").Style.cssText
HTML.getElementById("popup").innerHTML

HTML.getElementById("popup").getAttribute("style")
HTML.getElementById("popup").getAttribute("style").cssText
HTML.getElementById("popup").getAttribute("style",0)
HTML.getElementById("popup").getAttribute("style",0).cssText
HTML.getElementById("popup").Style.Visibility