HTMLDocument Practical Tools HTMLDocument method
name |
Description |
Detectencoding (Stream) |
Detects the encoding of an HTML stream. |
Detectencoding (TextReader) |
Detects the encoding of HTML text provided on a TextReader. |
Detectencoding (String) |
Detects the encoding of an HTML file. |
Detectencodingandload (String) |
Detects the encoding of HTML document from a file, and then loads the file. |
Detectencodingandload (String, Boolean) |
Detects the encoding of HTML document from a file, and then loads the file. |
Public Encoding detectencoding (Stream stream)
Detects the encoding of the HTML stream. The Detectencoding method is a member parameter of the htmlagilitypack.htmldocument :
Stream: the input stream. cannot be null. return:
The detected encoding.
The following example detects the encoding of the HTML stream.
var htmlnewdoc = new HTMLDocument ();
FileStream Newfs = new FileStream ("test.html", FileMode.Open);
var encoding = htmlnewdoc.detectencoding (NEWFS);
Public Encoding detectencoding (TextReader reader)
Detects the encoding of the HTML text provided on the TextReader. The Detectencoding method is a member parameter of the htmlagilitypack.htmldocument :
Reader: A textreader used to provide HTML. cannot be null. return:
The detected encoding.
The following example detects the encoding of the HTML text provided on TextReader.
var htmlnewdoc = new HTMLDocument ();
TextReader tr = file.opentext ("test.html");
var encoding = htmlnewdoc.detectencoding (TR);
Public Encoding detectencoding (string path)
Detects the encoding of an HTML file. The Detectencoding method is a member parameter of the htmlagilitypack.htmldocument :
Paths: The path to the file that contains the HTML document to be instrumented. cannot be null. return:
The detected encoding.
The following example detects the encoding of an HTML file.
var htmlnewdoc = new HTMLDocument ();
var encoding = htmlnewdoc.detectencoding ("test.html");
Public void Detectencodingandload (string path)
First, the encoding of the HTML document is detected from the file, and then the file is loaded. The Detectencodingandload method is a member parameter of the htmlagilitypack.htmldocument :
Path: The full file path to read.
The following example first detects the encoding of an HTML file and then loads it.
var htmlnewdoc = new HTMLDocument ();
Htmlnewdoc.detectencodingandload ("test.html");
Public void Detectencodingandload (string path, bool detectencoding)
Detects the encoding of HTML document from a file, and then loads the file. Detectencodingandload method is a htmlagilitypack.htmldocument
First, the encoding of the HTML document is detected from the file, and then the file is loaded. The Detectencodingandload method is a member parameter of the htmlagilitypack.htmldocument :
Path: The full file path to read. cannot be null.
Detectencoding: The detection encoding is true, or false.
The following example first detects the encoding of an HTML file and then loads it.
var htmlnewdoc = new HTMLDocument ();
Htmlnewdoc.detectencodingandload ("test.html", true);