I wrote the following code in order to retrieve data from an API and hopefully get the content of a specific element. I wrote similar code that works with web pages (not API) but in this example it breaks and don't understand why.
Sub parseXML()
Dim xmldoc As Object
Dim obj As Object
Dim MyRequest As Object
Set MyRequest = CreateObject("MSXML2.XMLHTTP")
MyRequest.Open "GET",
"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi? db=pubmed&term=ABL1%20Acute%20granulocytic%20leukemia"
MyRequest.send
While Not MyRequest.readyState = 4
DoEvents
Wend
Set xmldoc = MyRequest.responseXML
Set obj = xmldoc.DocumentElement.getElementsByClassName("ui-ncbihistogram-display-area")(0) 'Error: object doesn't support this property or method
End Sub
How should I write the last line in order to remove the error?
I am trying to get the element class="ui-ncbihistogram-display-area"
. It has several <li>
elements and at the end I want to retrieve the inner text of each of these<li>
elements.