CSharpTest.Net
Parse(String,AttributeFormat,IXmlLightReader) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightParser Class > Parse Method : Parse(String,AttributeFormat,IXmlLightReader) Method

content
format
reader

Glossary Item Box

Parses the provided xml/html document into discrete components and provides the information to the provided reader, see XmlLightDocument

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Sub Parse( _
   ByVal content As String, _
   ByVal format As XmlLightParser.AttributeFormat, _
   ByVal reader As IXmlLightReader _
) 
C# 
public static void Parse( 
   string content,
   XmlLightParser.AttributeFormat format,
   IXmlLightReader reader
)

Parameters

content
format
reader

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

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys