本文整理汇总了C#中HtmlElement.Nodes方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlElement.Nodes方法的具体用法?C# HtmlElement.Nodes怎么用?C# HtmlElement.Nodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlElement
的用法示例。
在下文中一共展示了HtmlElement.Nodes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add_HtmlObject
public void Add_HtmlObject(bool isVoid)
{
HtmlElement parent = new HtmlElement("parent", isVoid);
// Atribute
HtmlAttribute attribute = new HtmlAttribute("attribute");
parent.Add(attribute);
Assert.Equal(parent, attribute.Parent);
Assert.Equal(new HtmlAttribute[] { attribute }, parent.Attributes());
if (!isVoid)
{
// Element
HtmlElement element = new HtmlElement("element");
parent.Add(element);
Assert.Equal(parent, element.Parent);
Assert.Equal(new HtmlElement[] { element }, parent.Elements());
// Nodes
HtmlComment comment = new HtmlComment("comment");
parent.Add(comment);
Assert.Equal(parent, comment.Parent);
Assert.Equal(new HtmlObject[] { element, comment }, parent.Nodes());
}
}
示例2: ReplaceAll
public void ReplaceAll(HtmlObject[] content)
{
HtmlElement parent = new HtmlElement("parent", new HtmlElement("element"), new HtmlAttribute("attribute1"), new HtmlAttribute("attribute2"), new HtmlComment("comment"));
parent.ReplaceAll(content);
Assert.Equal(content.OfType<HtmlElement>().ToArray(), parent.Elements().ToArray());
Assert.Equal(content.OfType<HtmlAttribute>().ToArray(), parent.Attributes().ToArray());
Assert.Equal(parent.Elements().Count() + parent.Attributes().Count(), parent.ElementsAndAttributes().Count());
Assert.Equal(parent.Nodes().Count() + parent.Attributes().Count(), parent.NodesAndAttributes().Count());
}
示例3: Ctor_String_ParamsHtmlObject
public void Ctor_String_ParamsHtmlObject(HtmlObject[] content)
{
HtmlElement element = new HtmlElement("element", content);
Assert.Equal("element", element.Tag);
Assert.False(element.IsVoid);
Assert.Equal(content.OfType<HtmlElement>().ToArray(), element.Elements().ToArray());
Assert.Equal(content.OfType<HtmlAttribute>().ToArray(), element.Attributes().ToArray());
Assert.Equal(content.OfType<HtmlNode>().ToArray(), element.Nodes().ToArray());
Assert.Equal(element.Elements().Count() + element.Attributes().Count(), element.ElementsAndAttributes().Count());
Assert.Equal(content.Length, element.NodesAndAttributes().Count());
}
示例4: Add_ParamsHtmlObject_NonVoidElement
public void Add_ParamsHtmlObject_NonVoidElement()
{
HtmlElement parent = new HtmlElement("parent");
HtmlElement element = new HtmlElement("element");
HtmlAttribute attribute = new HtmlAttribute("attribute");
HtmlComment comment = new HtmlComment("comment");
parent.Add(new HtmlObject[] { element, attribute, comment });
Assert.Equal(parent, element.Parent);
Assert.Equal(parent, attribute.Parent);
Assert.Equal(new HtmlObject[] { element }, parent.Elements());
Assert.Equal(new HtmlAttribute[] { attribute }, parent.Attributes());
Assert.Equal(new HtmlObject[] { element, comment }, parent.Nodes());
}
示例5: WithInnerText
public void WithInnerText()
{
HtmlElement element = new HtmlElement("element");
Assert.Same(element, element.WithInnerText("InnerText"));
Assert.Equal(new HtmlNode[] { new HtmlText("InnerText") }, element.Nodes());
}
示例6: AddFirst_NonEmptyHtmlObject
public void AddFirst_NonEmptyHtmlObject(bool isVoid)
{
HtmlElement parent = new HtmlElement("parent", isVoid);
HtmlAttribute attribute1 = new HtmlAttribute("attribute1");
parent.Add(attribute1);
// Attributes
HtmlAttribute attribute2 = new HtmlAttribute("attribute2");
parent.AddFirst(attribute2);
Assert.Equal(parent, attribute2.Parent);
Assert.Equal(new HtmlAttribute[] { attribute2, attribute1 }, parent.Attributes());
if (!isVoid)
{
HtmlElement element1 = new HtmlElement("element1");
parent.Add(element1);
// Elements
HtmlElement element2 = new HtmlElement("element2");
parent.AddFirst(element2);
Assert.Equal(parent, element2.Parent);
Assert.Equal(new HtmlElement[] { element2, element1 }, parent.Elements());
// Nodes
HtmlComment comment = new HtmlComment("comment");
parent.AddFirst(comment);
Assert.Equal(parent, comment.Parent);
Assert.Equal(new HtmlObject[] { comment, element2, element1 }, parent.Nodes());
}
}