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

Glossary Item Box

Returns the children of this html element

Syntax

Visual Basic (Declaration) 
Public ReadOnly Children As List(Of XmlLightElement)
C# 
public readonly List<XmlLightElement> Children

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