DetectEncodingAndLoad

public void DetectEncodingAndLoad(string path)

Detects the encoding of an HTML document from a file first, and then loads the file. DetectEncodingAndLoad method is a member of HtmlAgilityPack.HtmlDocument

Parameters:

path: The complete file path to be read.

Example

The following example detects the encoding of an HTML file first, and then loads it.

var htmlNewDoc = new HtmlDocument();

htmlNewDoc.DetectEncodingAndLoad("Test.html");

Click here to run this example.

public void DetectEncodingAndLoad(string path, bool detectEncoding)

Detects the encoding of an HTML document from a file first, and then loads the file. DetectEncodingAndLoad method is a member of HtmlAgilityPack.HtmlDocument

Parameters:

path: The complete file path to be read. May not be null. detectEncoding: true to detect encoding, false otherwise.

Example

The following example detects the encoding of an HTML file first, and then loads it. https://dotnetfiddle.net/LqhqAq

var htmlNewDoc = new HtmlDocument();

htmlNewDoc.DetectEncodingAndLoad("Test.html", true);

Click here to run this example.