简体   繁体   中英

How to extract a particular inner-text value of an elements when there are many classname have similar names

I am trying to extract the innertext value of an element whose attribute name is same with 4 others elements in a webpage.

Difference is I am trying to extract only the innertext value of 3rd element (which begins with numericals For ex. 123123123) . While other 3 elements have innertext values starting with non numeric values (EX GA1233412FGH).

Please let me know how can do this.

Below is my code snippet. Here attributename= jobid is the same with 3 other webelements.

    Set objSubCollec = objCollection(0).contentWindow.document.getElementById("tab")
    Set objElement = objSubCollec.contentWindow.document.getElementById("Frame_4")
    objElement.Focus
    Set objElement = objElement.contentWindow.document
    Set elm = objElement1.getElementsByTagName("span")
        i = 6
          For Each e1 In elm
              If e1.getAttribute("orafield") = "jobid" 'jobid is the common attribute name with 4 other elements
                 temp = e1.innerText
                 Worksheets("Sheet1").Range("C6") = temp
                 i = i + 1
                 'MsgBox temp
          End If
          Next

Assuming the innertext you want to extract always starts with numeric value, and the other elements don't, you can just add a simple condition:

If IsNumeric(Mid(el, 1, 1)) Then

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM