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

content
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 reader As IXmlLightReader _
) 
C# 
public static void Parse( 
   string content,
   IXmlLightReader reader
)

Parameters

content
reader

Example

Library/Library.Test/TestHtmlParser.cs

C#Copy Code
string notxml = "<html id=a ><body foo='bar' bar=\"foo\" />";

HtmlLightDocument html = new HtmlLightDocument();
XmlLightParser.Parse(notxml, html);
Assert.AreEqual("html", html.Root.TagName);
Assert.AreEqual(1, html.Root.Attributes.Count);
Assert.AreEqual("a", html.Root.Attributes["id"]);
Assert.AreEqual(1, html.Root.Children.Count);
Assert.AreEqual("body", html.Root.Children[0].TagName);
Assert.AreEqual("foo", html.Root.Children[0].Attributes["bar"]);
Assert.AreEqual("bar", html.Root.Children[0].Attributes["foo"]);

XmlLightDocument xml = new XmlLightDocument();
XmlLightParser.Parse(notxml, XmlLightParser.AttributeFormat.Xml, xml);
Assert.AreEqual(2, xml.Root.Attributes.Count);
//Not recognized: xml.Root.Attributes["id"]
Assert.AreEqual("body", xml.Root.TagName);
Assert.AreEqual("foo", xml.Root.Attributes["bar"]);
Assert.AreEqual("bar", xml.Root.Attributes["foo"]);
VB.NETCopy Code
Dim notxml As String = "<html id=a ><body foo='bar' bar=""foo"" />"

Dim html As New HtmlLightDocument()
XmlLightParser.Parse(notxml, html)
Assert.AreEqual("html", html.Root.TagName)
Assert.AreEqual(1, html.Root.Attributes.Count)
Assert.AreEqual("a", html.Root.Attributes("id"))
Assert.AreEqual(1, html.Root.Children.Count)
Assert.AreEqual("body", html.Root.Children(0).TagName)
Assert.AreEqual("foo", html.Root.Children(0).Attributes("bar"))
Assert.AreEqual("bar", html.Root.Children(0).Attributes("foo"))

Dim xml As New XmlLightDocument()
XmlLightParser.Parse(notxml, XmlLightParser.AttributeFormat.Xml, xml)
Assert.AreEqual(2, xml.Root.Attributes.Count)
'Not recognized: xml.Root.Attributes["id"]
Assert.AreEqual("body", xml.Root.TagName)
Assert.AreEqual("foo", xml.Root.Attributes("bar"))
Assert.AreEqual("bar", xml.Root.Attributes("foo"))

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys