Visual Basic (Declaration) | |
---|---|
Public ReadOnly Property TagName As String |
C# | |
---|---|
public string TagName {get;} |
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.NET | Copy 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")) |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
XmlLightElement ClassXmlLightElement Members
Used By
XmlLightElement.WriteXml(XmlWriter)XmlLightElement.WriteUnformatted(TextWriter)
XmlLightDocument.EndTag(XmlTagInfo)
XmlLightDocument.EndDocument()
HtmlLightDocument.StartTag(XmlTagInfo)
HtmlLightDocument.EndTag(XmlTagInfo)
HtmlLightDocument.EndDocument()