adding additional column to an existing html table

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 2 years, 2 months ago.

  • Author
  • #39032

    amit aman

    Hi Team,

    I have 3 tables just created by using Invoke-WebRequest. I want to 2 additional similar columns to all the 3 tables it. Kindly suggest. Following is my code:

    $URL = ""
    $data = Invoke-WebRequest -Uri $URL
    $tables = @($data.ParsedHtml.getElementsByTagName("TABLE")).OuterHTML | Out-File C:\test\dd.html

  • #39214

    Don Jones

    So... $tables is empty, because you sent the data to Out-File.

    Assuming you had not done so, $tables would be raw HTML. There's not really a trick or magic way to manipulate that. It gets down to string manipulation – PowerShell doesn't have anything that'd make this easier on you. And assuming you want each row to have two new columns... it's going to be really hard.

    If in fact you're JUST capturing an HTML table, from the opening and closing TABLE tags, you might try casting it as XML. You'd get a document object model, at least, and maybe you could add nodes to that and then save it out as text.

You must be logged in to reply to this topic.