CSharpTest.Net
TagName Property
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : TagName Property

Glossary Item Box

Returns the tag name of this html element

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property TagName As String
C# 
public string TagName {get;}

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