|
4 | 4 | .DESCRIPTION |
5 | 5 | Long description |
6 | 6 | .EXAMPLE |
7 | | - PS C:\> <example usage> |
8 | | - Explanation of what the example does |
| 7 | + PS C:\> $HTMLString = @" |
| 8 | + <!DOCTYPE html> |
| 9 | + <html> |
| 10 | + <body> |
| 11 | + <h1>My First Heading</h1> |
| 12 | + <p>My first paragraph.</p>d |
| 13 | + </body> |
| 14 | + </html> |
| 15 | + "@ |
| 16 | + PS C:\> $HTMLString | ConvertFrom-HTML -OutVariable result |
| 17 | +
|
| 18 | +NodeType Name AttributeCount ChildNodeCount ContentLength InnerText |
| 19 | +-------- ---- -------------- -------------- ------------- --------- |
| 20 | +Document #document 0 4 103 … |
| 21 | +
|
| 22 | + PS C:\> $result.SelectSingleNode("//body/h1") |
| 23 | +
|
| 24 | +NodeType Name AttributeCount ChildNodeCount ContentLength InnerText |
| 25 | +-------- ---- -------------- -------------- ------------- --------- |
| 26 | +Element h1 0 1 16 My First Heading |
| 27 | +
|
| 28 | + Convert HTML string to a HtmlNode via the pipeline. |
| 29 | +
|
| 30 | +.EXAMPLE |
| 31 | + PS C:\> $uri = "https://www.powershellgallery.com/" |
| 32 | + PS C:\> $result = ConvertFrom-HTML -uri $uri |
| 33 | + PS C:\> $result |
| 34 | +
|
| 35 | +NodeType Name AttributeCount ChildNodeCount ContentLength InnerText |
| 36 | +-------- ---- -------------- -------------- ------------- --------- |
| 37 | +Document #document 0 4 17550 … |
| 38 | +
|
| 39 | + Fetch and parse $uri directly via the URI pipeline. |
| 40 | +.EXAMPLE |
| 41 | + PS C:\> Get-Item $testFilePath | ConvertFrom-Html |
| 42 | +
|
| 43 | +NodeType Name AttributeCount ChildNodeCount ContentLength InnerText |
| 44 | +-------- ---- -------------- -------------- ------------- --------- |
| 45 | +Document #document 0 5 105 … |
| 46 | +
|
| 47 | + Parse an HTML file piped from Get-Item. |
9 | 48 | .INPUTS |
10 | 49 | [String[]] |
11 | 50 | [System.IO.FileInfo[]] |
|
0 commit comments