当前位置: 首页>>代码示例>>C#>>正文


C# HtmlElement.Nodes方法代码示例

本文整理汇总了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());
            }
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:25,代码来源:HtmlElement.AddTests.cs

示例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());
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:10,代码来源:HtmlElement.ReplaceTests.cs

示例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());
 }
开发者ID:hughbe,项目名称:html-generator,代码行数:11,代码来源:HtmlElementTests.cs

示例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());
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:14,代码来源:HtmlElement.AddTests.cs

示例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());
 }
开发者ID:hughbe,项目名称:html-generator,代码行数:6,代码来源:TagTests.cs

示例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());
            }
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:30,代码来源:HtmlElement.AddTests.cs


注:本文中的HtmlElement.Nodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。