title: How to Convert HTML table to CSV file with same structure with powershell
body: <p>With Powershell, I can get the table with this -
  $URL = "<a href="http://example.com/yyy.htm" rel="nofollow noreferrer">http://example.com/yyy.htm</a>"
  $OutputFile = "$env:temp\tempfile.xml"</p>
  
  <pre><code># reading website data:
  $data = Invoke-WebRequest -Uri $URL 
  
  # get the first table found on the website and write it to disk:
  @($data.ParsedHtml.getElementsByTagName("table"))[0].OuterHTML | Set-Content -Path $OutputFile
  </code></pre>
  
  <p>Now I want this table to be converted to CSV... How do I do that?</p>
  
  <p>Table example -</p>
  
  <pre><code>Datacenter | FirstDNS | SecondDNS | ThirdDNS | FourthDNS
  -----------------------------------------------------------
  NewYork    | 1.1.1.1  | 2.2.2.2   |3.3.3.3   | 4.4.4.4
  India      | 1.2.3.4  | 3.2.6.5   |8.2.3.7   | 8.3.66.1
  </code></pre>