adding additional column to an existing html table

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 4 months, 2 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #39032
    Profile photo of amit aman
    amit aman
    Participant

    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 = "https://support.sourcefire.com/supplemental/sf-rules-2015-05-12-seu.html"
    $data = Invoke-WebRequest -Uri $URL
    $tables = @($data.ParsedHtml.getElementsByTagName("TABLE")).OuterHTML | Out-File C:\test\dd.html

    #39214
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.