CSharpTest.Net
HtmlLightDocument Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : HtmlLightDocument Class

Glossary Item Box

Represents a loosly parsed html document

Object Model

HtmlLightDocument ClassXmlLightElement ClassXmlLightElement ClassXmlLightElement ClassXmlLightElement Class

Syntax

Visual Basic (Declaration) 
Public Class HtmlLightDocument 
   Inherits XmlLightDocument
   Implements IXmlLightReader 
C# 
public class HtmlLightDocument : XmlLightDocument, IXmlLightReader  

Example

Library/Library.Test/TestHtmlParser.cs

C#Copy Code
string[] files = Directory.GetFiles(@"c:\temp\trash", "*.htm", SearchOption.AllDirectories);
System.Diagnostics.Stopwatch sw;

for (int i = 0; i < 10; i++)
{
    //HTML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new HtmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds);
    //XML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new XmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds);
    //Parse Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    IXmlLightReader rdr = new EmptyReader();
    foreach (string file in files)
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr);

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds);
    //Text Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        XmlLightParser.ParseText(File.ReadAllText(file));

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds);
}
VB.NETCopy Code
Dim files As String() = Directory.GetFiles("c:\temp\trash", "*.htm", SearchOption.AllDirectories)
Dim sw As System.Diagnostics.Stopwatch

Dim i As Integer = 0
While i < 10
    'HTML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New HtmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds)
    'XML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New XmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds)
    'Parse Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    Dim rdr As IXmlLightReader = New EmptyReader()
    For Each file As String In files
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr)
    Next

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds)
    'Text Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        XmlLightParser.ParseText(File.ReadAllText(file))
    Next

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Inheritance Hierarchy

System.Object
   CSharpTest.Net.Html.XmlLightElement
      CSharpTest.Net.Html.XmlLightDocument
         CSharpTest.Net.Html.HtmlLightDocument

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys