0

I'm developing an Autohotkey script to ultimately return the value of the node in this table row (ie '4'), but I'm getting stuck half way.

<tr>
<th scope="row" class="infobox-label">Platforms</th>
<td class="infobox-data">4</td>
</tr>

It's the table tiled 'Wrexham General' on the right hand side of this page:

https://en.wikipedia.org/wiki/Wrexham_General_railway_station

I've checked that the table is well formed XML. (The webpage HTML is not).

xpObj is returning 0 but should be 23. I'm using Xpath as suggested here: How to get element by innerText.

Am I passing the correct data within Table?

Am I right in thinking //tr should return all table rows no matter where they are in the table?

whr :=  ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", "https://en.wikipedia.org/wiki/Wrexham General railway station")
whr.Send()
oHTML := ComObjCreate("HTMLFile")
oHTML.write(whr.ResponseText)
document := oHTML

Table := document.getElementsByClassName("infobox vcard ib-station")[0].outerHTML
MsgBox % "Table:  `n" Table 

xmldoc := ComObjCreate("MSXML2.DOMDocument.6.0")
xmldoc.setProperty("SelectionLanguage", "XPath")
xmldoc.async := false
xmldoc.loadXML(Table)
xpObj := xmldoc.selectNodes("//tr").length
msgbox % xpObj
DaveF
  • 101
  • 9

0 Answers0