0

Below is the HTML DOM, I want to store DatePlannedStartTimeStamp value "01/24/2017 18:00" in a variable, print and call later

<TD class=dbData><SPAN onmouseover="ShowDay(this.innerHTML, 231320)" 
onmouseout=nd() id=DatePlannedStartTimeStamp>01/24/2017 18:00</SPAN></TD>

I tried below but it does not return any value

$HTML = Invoke-WebRequest -Uri $URL -UseDefaultCredential
$WebPageText = ($HTML.ParsedHtml.getElementsByTagName("a") | Where- 
Object{$_.ID -match "DatePlannedStartTimeStamp"}).innerText
echo $WebPageText

Not sure if my tagname is correct. I'm still learning powershell script, it would be great help if there is a way to it.

Madhan
  • 3
  • 2
  • 3
    You're getting `a` elements, but the `id` attribute is part of a `span`. – Daniel Mann Sep 14 '18 at 21:30
  • I don't recommend parsing html yourself. [There's a nice library called htmlagility](https://github.com/zzzprojects/html-agility-pack) you can use instead. At that point you could read through the HTML like XML and use xPath: `$html.SelectNodes('//span[@id="DatePlannedStartTimeStamp"]/text()').Value` – Maximilian Burszley Sep 14 '18 at 22:49
  • @DanielMann - Thank you for looking at it. So how would the script be? If you could please give an example from above that would be great. – Madhan Sep 15 '18 at 19:22
  • @TheIncorrigible1 - Thank you for the suggestion. I still have to explore your recommendation. Is there a wa that I can match the values */*/* *:* to get the date/time – Madhan Sep 15 '18 at 19:51

0 Answers0