本文整理汇总了C#中MariGold.HtmlParser.HtmlTextParser类的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextParser类的具体用法?C# HtmlTextParser怎么用?C# HtmlTextParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HtmlTextParser类属于MariGold.HtmlParser命名空间,在下文中一共展示了HtmlTextParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MultiLayerWithNoInheritance
public void MultiLayerWithNoInheritance()
{
string html = "<div style='font-family:arial;width:10px'><div><span>test</span></div></div>";
HtmlParser parser = new HtmlTextParser(html);
Assert.IsTrue(parser.Parse());
parser.ParseStyles();
Assert.IsNotNull(parser.Current);
IHtmlNode node = parser.Current;
node.AnalyzeNode("div", "<div><span>test</span></div>", html, null, false, true, 1, 1, 2);
node.Attributes.CheckKeyValuePair(0, "style", "font-family:arial;width:10px");
node.Styles.CheckKeyValuePair(0, "font-family", "arial");
node.Styles.CheckKeyValuePair(1, "width", "10px");
node.Children.ElementAt(0).AnalyzeNode("div", "<span>test</span>", "<div><span>test</span></div>", node, false, true, 1, 0, 0);
Assert.AreEqual(1, node.Children.ElementAt(0).InheritedStyles.Count);
node.Children.ElementAt(0).CheckInheritedStyle(0, "font-family", "arial");
node.Children.ElementAt(0).Children.ElementAt(0).AnalyzeNode("span", "test", "<span>test</span>", node.Children.ElementAt(0), false, true, 1, 0, 0);
Assert.AreEqual(1, node.Children.ElementAt(0).Children.ElementAt(0).InheritedStyles.Count);
node.Children.ElementAt(0).Children.ElementAt(0).CheckInheritedStyle(0, "font-family", "arial");
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:26,代码来源:CSSInheritance.cs
示例2: BrWithNoSpaceAndSpan
public void BrWithNoSpaceAndSpan()
{
string html = @"<br/><span>1</span>";
HtmlParser parser = new HtmlTextParser(html);
Assert.AreEqual(true, parser.Traverse());
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "br", "<br/>", "<br/>");
Assert.IsNull(parser.Current.Parent);
Assert.AreEqual(0, parser.Current.Children.Count());
Assert.AreEqual(false, parser.Current.HasChildren);
Assert.AreEqual(true, parser.Current.SelfClosing);
Assert.AreEqual(true, parser.Traverse());
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "span", "1", "<span>1</span>");
Assert.IsNull(parser.Current.Parent);
Assert.AreEqual(1, parser.Current.Children.Count());
Assert.AreEqual(true, parser.Current.HasChildren);
Assert.AreEqual(false, parser.Current.SelfClosing);
Assert.IsNotNull(parser.Current.Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0), "#text", "1", "1");
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Parent);
Assert.AreEqual(parser.Current, parser.Current.Children.ElementAt(0).Parent);
Assert.AreEqual(0, parser.Current.Children.ElementAt(0).Children.Count());
Assert.AreEqual(false, parser.Current.Children.ElementAt(0).HasChildren);
Assert.AreEqual(false, parser.Current.Children.ElementAt(0).SelfClosing);
Assert.AreEqual(false, parser.Traverse());
Assert.IsNull(parser.Current);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:33,代码来源:SelfClosing.cs
示例3: DivInsidePWithUpperCaseClose
public void DivInsidePWithUpperCaseClose()
{
string html = "<div><p></P></DIV>";
HtmlParser parser = new HtmlTextParser(html);
Assert.AreEqual(true, parser.Traverse());
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "div", "<p></P>", html);
Assert.IsNull(parser.Current.Parent);
Assert.AreEqual(true, parser.Current.HasChildren);
Assert.AreEqual(1, parser.Current.Children.Count());
Assert.AreEqual(false, parser.Current.SelfClosing);
Assert.AreEqual(0, parser.Current.Attributes.Count);
Assert.IsNotNull(parser.Current.Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0), "p", "", "<p></P>");
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Parent);
Assert.AreEqual(parser.Current, parser.Current.Children.ElementAt(0).Parent);
Assert.AreEqual(false, parser.Current.Children.ElementAt(0).HasChildren);
Assert.AreEqual(0, parser.Current.Children.ElementAt(0).Children.Count());
Assert.AreEqual(false, parser.Current.Children.ElementAt(0).SelfClosing);
Assert.AreEqual(0, parser.Current.Attributes.Count);
Assert.AreEqual(parser.Traverse(), false);
Assert.IsNull(parser.Current);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:27,代码来源:CaseSensitiveTags.cs
示例4: TwoRowWithOneColumnEach
public void TwoRowWithOneColumnEach()
{
string html = "<table><tr><td>test1</td></tr><tr><td>test2</td></tr></table>";
HtmlTextParser parser = new HtmlTextParser(html);
Assert.AreEqual(true, parser.Traverse());
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "table", "<tr><td>test1</td></tr><tr><td>test2</td></tr>", html);
Assert.IsNull(parser.Current.Parent);
Assert.IsNotNull(parser.Current.Children);
Assert.AreEqual(2, parser.Current.Children.Count());
Assert.IsNotNull(parser.Current.Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0), "tr", "<td>test1</td>", "<tr><td>test1</td></tr>");
Assert.AreEqual(parser.Current, parser.Current.Children.ElementAt(0).Parent);
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Children);
Assert.AreEqual(1, parser.Current.Children.ElementAt(0).Children.Count());
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0).Children.ElementAt(0), "td", "test1", "<td>test1</td>");
Assert.AreEqual(parser.Current.Children.ElementAt(0), parser.Current.Children.ElementAt(0).Children.ElementAt(0).Parent);
Assert.IsNotNull(parser.Current.Children.ElementAt(1));
TestUtility.AreEqual(parser.Current.Children.ElementAt(1), "tr", "<td>test2</td>", "<tr><td>test2</td></tr>");
Assert.AreEqual(parser.Current, parser.Current.Children.ElementAt(1).Parent);
Assert.IsNotNull(parser.Current.Children.ElementAt(1).Children);
Assert.AreEqual(1, parser.Current.Children.ElementAt(1).Children.Count());
Assert.IsNotNull(parser.Current.Children.ElementAt(1).Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(1).Children.ElementAt(0), "td", "test2", "<td>test2</td>");
Assert.AreEqual(parser.Current.Children.ElementAt(1), parser.Current.Children.ElementAt(1).Children.ElementAt(0).Parent);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:35,代码来源:Tables.cs
示例5: FontSizeLineHeightFontFamily
public void FontSizeLineHeightFontFamily()
{
string html = "<div style='font:25px/2pt arial'><div style='font-family:verdana'>test</div></div>";
HtmlParser parser = new HtmlTextParser(html);
Assert.IsTrue(parser.Parse());
parser.ParseStyles();
IHtmlNode node = parser.Current;
Assert.IsNotNull(node);
TestUtility.AnalyzeNode(node, "div", "<div style='font-family:verdana'>test</div>", html, null, false, true, 1, 1, 3);
node.CheckStyle(0, "font-size", "25px");
node.CheckStyle(1, "line-height", "2pt");
node.CheckStyle(2, "font-family", "arial");
IHtmlNode parent = node;
node = node.Children.ElementAt(0);
Assert.IsNotNull(node);
TestUtility.AnalyzeNode(node, "div", "test", "<div style='font-family:verdana'>test</div>", parent, false, true, 1, 1, 1);
node.CheckStyle(0, "font-family", "verdana");
Assert.AreEqual(3, node.InheritedStyles.Count);
node.CheckInheritedStyle(0, "font-size", "25px");
node.CheckInheritedStyle(1, "line-height", "2pt");
node.CheckInheritedStyle(2, "font-family", "verdana");
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:26,代码来源:FontStyle.cs
示例6: DivInsideTextA
public void DivInsideTextA()
{
string html = "<div>test<a>ano</a></div>";
HtmlParser parser = new HtmlTextParser(html);
Assert.AreEqual(true, parser.Traverse());
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "div", "test<a>ano</a>", "<div>test<a>ano</a></div>");
Assert.IsNull(parser.Current.Previous);
Assert.IsNull(parser.Current.Next);
Assert.AreEqual(2, parser.Current.Children.Count());
Assert.IsNotNull(parser.Current.Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0), "#text", "test", "test");
Assert.IsNull(parser.Current.Children.ElementAt(0).Previous);
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Next);
Assert.AreEqual(parser.Current.Children.ElementAt(0).Next, parser.Current.Children.ElementAt(1));
Assert.IsNotNull(parser.Current.Children.ElementAt(1));
TestUtility.AreEqual(parser.Current.Children.ElementAt(1), "a", "ano", "<a>ano</a>");
Assert.IsNull(parser.Current.Children.ElementAt(1).Next);
Assert.IsNotNull(parser.Current.Children.ElementAt(1).Previous);
Assert.AreEqual(parser.Current.Children.ElementAt(1).Previous, parser.Current.Children.ElementAt(0));
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:25,代码来源:PreviousNextNodes.cs
示例7: ClassAttribute
public void ClassAttribute()
{
string html = @"<style>
.cls
{
color:red;
}
[attr]
{
color:blue;
}
</style>
<div class='cls' attr></div>";
HtmlParser parser = new HtmlTextParser(html);
Assert.IsTrue(parser.Parse());
parser.ParseStyles();
Assert.IsNotNull(parser.Current);
IHtmlNode node = parser.Current;
while (node.Tag != "div")
{
node = node.Next;
}
TestUtility.AnalyzeNode(node, "div", "", "<div class='cls' attr></div>", null, false, false, 0, 2, 1);
TestUtility.CheckKeyValuePair(node.Attributes.ElementAt(0), "class", "cls");
TestUtility.CheckKeyValuePair(node.Attributes.ElementAt(1), "attr", "");
TestUtility.CheckKeyValuePair(node.Styles.ElementAt(0), "color", "blue");
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:34,代码来源:CSSelectorTypePriority.cs
示例8: CommentWithMediaQuery
public void CommentWithMediaQuery()
{
string path = TestUtility.GetFolderPath("Html\\commentwithmediaquery.htm");
string html = string.Empty;
using (StreamReader sr = new StreamReader(path))
{
html = sr.ReadToEnd();
}
HtmlParser parser = new HtmlTextParser(html);
Assert.AreEqual(true, parser.Parse());
parser.ParseStyles();
IHtmlNode node = parser.Current;
while (node.Tag != "html")
node = node.Next;
node = node.Children.ElementAt(0);
while (node.Tag != "body")
node = node.Next;
IHtmlNode body=node;
node = node.Children.ElementAt(0);
while (node.Tag != "p")
node = node.Next;
TestUtility.AnalyzeNode(node, "p", "test", "<p>test</p>", body, false, true, 1, 0, 0);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:34,代码来源:CSSComments.cs
示例9: DivP
public void DivP()
{
string html = "<div><p></div>";
HtmlParser parser = new HtmlTextParser(html);
Assert.AreEqual(true, parser.Traverse());
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "div", "<p>", "<div><p></div>");
Assert.IsNull(parser.Current.Parent);
Assert.AreEqual(1, parser.Current.Children.Count());
Assert.AreEqual(true, parser.Current.HasChildren);
Assert.AreEqual(false, parser.Current.SelfClosing);
Assert.IsNotNull(parser.Current.Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0), "p", "", "<p>");
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Parent);
Assert.AreEqual(parser.Current, parser.Current.Children.ElementAt(0).Parent);
Assert.AreEqual(false, parser.Current.Children.ElementAt(0).HasChildren);
Assert.AreEqual(0, parser.Current.Children.ElementAt(0).Children.Count());
Assert.AreEqual(false, parser.Current.Children.ElementAt(0).SelfClosing);
Assert.AreEqual(false, parser.Traverse());
Assert.IsNull(parser.Current);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:25,代码来源:InvalidOpenClose.cs
示例10: OpenOnlyDivAndValidDiv
public void OpenOnlyDivAndValidDiv()
{
string html = "<div><div>test</div>";
HtmlParser parser = new HtmlTextParser(html);
if (parser.Traverse())
{
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "div", "<div>test</div>", "<div><div>test</div>");
Assert.IsNull(parser.Current.Parent);
Assert.IsNotNull(parser.Current.Children);
Assert.AreEqual(parser.Current.Children.Count(), 1);
Assert.IsNotNull(parser.Current.Children.ElementAt(0));
IHtmlNode node = parser.Current.Children.ElementAt(0);
Assert.IsNotNull(node.Parent);
TestUtility.AreEqual(node, "div", "test", "<div>test</div>");
}
else
{
Assert.Fail("Fail to traverse");
}
Assert.AreEqual(parser.Traverse(), false);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:33,代码来源:InvalidMultiElements.cs
示例11: DivInsidePAndB
public void DivInsidePAndB()
{
string html = "<div><p>one</p></div><b></b>";
HtmlParser parser = new HtmlTextParser(html);
Assert.IsTrue(parser.Parse());
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "div", "<p>one</p>", "<div><p>one</p></div>");
Assert.IsTrue(parser.Current.HasChildren);
Assert.AreEqual(1, parser.Current.Children.Count());
Assert.IsNotNull(parser.Current.Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0), "p", "one", "<p>one</p>");
Assert.IsNull(parser.Current.Children.ElementAt(0).Previous);
Assert.IsNull(parser.Current.Children.ElementAt(0).Next);
Assert.IsNull(parser.Current.Previous);
Assert.IsNotNull(parser.Current.Next);
TestUtility.AreEqual(parser.Current.Next, "b", "", "<b></b>");
Assert.IsNull(parser.Current.Next.Next);
Assert.IsNotNull(parser.Current.Next.Previous);
Assert.AreEqual(parser.Current, parser.Current.Next.Previous);
Assert.IsFalse(parser.Parse());
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:25,代码来源:ParseMethod.cs
示例12: SimpleTable
public void SimpleTable()
{
string html = "<table><tr><td>1</td></tr></table>";
HtmlTextParser parser = new HtmlTextParser(html);
Assert.AreEqual(true, parser.Traverse());
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "table", "<tr><td>1</td></tr>", "<table><tr><td>1</td></tr></table>");
Assert.IsNull(parser.Current.Parent);
Assert.IsNotNull(parser.Current.Children);
Assert.AreEqual(1, parser.Current.Children.Count());
Assert.IsNotNull(parser.Current.Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0), "tr", "<td>1</td>", "<tr><td>1</td></tr>");
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Parent);
Assert.AreEqual(parser.Current.Children.ElementAt(0).Parent, parser.Current);
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Children);
Assert.AreEqual(1, parser.Current.Children.ElementAt(0).Children.Count());
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0).Children.ElementAt(0), "td", "1", "<td>1</td>");
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Children.ElementAt(0).Parent);
Assert.AreEqual(parser.Current.Children.ElementAt(0).Children.ElementAt(0).Parent, parser.Current.Children.ElementAt(0));
Assert.AreEqual(parser.Traverse(), false);
Assert.IsNull(parser.Current);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:29,代码来源:Tables.cs
示例13: DivAndInvalidDiv
public void DivAndInvalidDiv()
{
string html = "<div>test1</div><div>test2";
HtmlParser parser = new HtmlTextParser(html);
if (parser.Traverse())
{
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "div", "test1", "<div>test1</div>");
}
else
{
Assert.Fail("Fail to traverse");
}
if (parser.Traverse())
{
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "div", "test2", "<div>test2");
}
else
{
Assert.Fail("Fail to traverse");
}
Assert.AreEqual(parser.Traverse(), false);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:30,代码来源:InvalidMultiElements.cs
示例14: FindBodyOrFirstElement
public IHtmlNode FindBodyOrFirstElement()
{
MariGold.HtmlParser.HtmlParser parser = new HtmlTextParser(html);
parser.UriSchema = uriSchema;
parser.BaseURL = baseUrl;
parser.Parse();
parser.ParseStyles();
IHtmlNode node = parser.Current;
IHtmlNode body = null;
while (node != null)
{
body = FindBody(node);
if (body != null || node.Next == null)
{
break;
}
node = node.Next;
}
return body ?? parser.Current;
}
开发者ID:kannan-ar,项目名称:MariGold.OpenXHTML,代码行数:27,代码来源:HtmlParser.cs
示例15: TextDivSpan
public void TextDivSpan()
{
string html = "test<div>this is a div</div><span>this is a span</span>";
HtmlParser parser = new HtmlTextParser(html);
if (parser.Traverse())
{
Assert.IsNotNull(parser.Current);
if (parser.Current != null)
{
Assert.AreEqual("#text", parser.Current.Tag);
Assert.AreEqual("test", parser.Current.Html);
Assert.AreEqual("test", parser.Current.InnerHtml);
}
}
else
{
Assert.Fail("Fail to traverse");
}
if (parser.Traverse())
{
Assert.IsNotNull(parser.Current);
if (parser.Current != null)
{
Assert.AreEqual("div", parser.Current.Tag);
Assert.AreEqual("<div>this is a div</div>", parser.Current.Html);
Assert.AreEqual("this is a div", parser.Current.InnerHtml);
}
}
else
{
Assert.Fail("Fail to traverse");
}
if (parser.Traverse())
{
Assert.IsNotNull(parser.Current);
if (parser.Current != null)
{
Assert.AreEqual("span", parser.Current.Tag);
Assert.AreEqual("<span>this is a span</span>", parser.Current.Html);
Assert.AreEqual("this is a span", parser.Current.InnerHtml);
}
}
else
{
Assert.Fail("Fail to traverse");
}
Assert.AreEqual(parser.Traverse(), false);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:58,代码来源:ThreeElements.cs
示例16: DivPSpanTextInvalidSpanOpen
public void DivPSpanTextInvalidSpanOpen()
{
string html = "<div><p><span>test<span></p></div>";
HtmlParser parser = new HtmlTextParser(html);
Assert.AreEqual(true, parser.Traverse());
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "div", "<p><span>test<span></p>", html);
Assert.IsNull(parser.Current.Parent);
Assert.AreEqual(1, parser.Current.Children.Count());
Assert.AreEqual(true, parser.Current.HasChildren);
Assert.AreEqual(false, parser.Current.SelfClosing);
Assert.AreEqual(0, parser.Current.Attributes.Count);
Assert.IsNotNull(parser.Current.Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0), "p", "<span>test<span>", "<p><span>test<span></p>");
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Parent);
Assert.AreEqual(parser.Current, parser.Current.Children.ElementAt(0).Parent);
Assert.AreEqual(1, parser.Current.Children.ElementAt(0).Children.Count());
Assert.AreEqual(true, parser.Current.Children.ElementAt(0).HasChildren);
Assert.AreEqual(false, parser.Current.Children.ElementAt(0).SelfClosing);
Assert.AreEqual(0, parser.Current.Children.ElementAt(0).Attributes.Count);
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0).Children.ElementAt(0), "span", "test<span>", "<span>test<span>");
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Children.ElementAt(0).Parent);
Assert.AreEqual(parser.Current.Children.ElementAt(0), parser.Current.Children.ElementAt(0).Children.ElementAt(0).Parent);
Assert.AreEqual(2, parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.Count());
Assert.AreEqual(true, parser.Current.Children.ElementAt(0).Children.ElementAt(0).HasChildren);
Assert.AreEqual(false, parser.Current.Children.ElementAt(0).Children.ElementAt(0).SelfClosing);
Assert.AreEqual(0, parser.Current.Children.ElementAt(0).Children.ElementAt(0).Attributes.Count);
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(0));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(0), "#text", "test", "test");
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(0).Parent);
Assert.AreEqual(parser.Current.Children.ElementAt(0).Children.ElementAt(0),
parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(0).Parent);
Assert.AreEqual(0, parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(0).Children.Count());
Assert.AreEqual(false, parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(0).HasChildren);
Assert.AreEqual(false, parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(0).SelfClosing);
Assert.AreEqual(0, parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(0).Attributes.Count);
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(1));
TestUtility.AreEqual(parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(1), "span", "", "<span>");
Assert.IsNotNull(parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(1).Parent);
Assert.AreEqual(parser.Current.Children.ElementAt(0).Children.ElementAt(0),
parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(1).Parent);
Assert.AreEqual(0, parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(1).Children.Count());
Assert.AreEqual(false, parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(1).HasChildren);
Assert.AreEqual(false, parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(1).SelfClosing);
Assert.AreEqual(0, parser.Current.Children.ElementAt(0).Children.ElementAt(0).Children.ElementAt(1).Attributes.Count);
Assert.AreEqual(false, parser.Traverse());
Assert.IsNull(parser.Current);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:56,代码来源:InvalidOpenClose.cs
示例17: InputWithEmptyQuote
public void InputWithEmptyQuote()
{
string html = "<input \"\" />";
HtmlParser parser = new HtmlTextParser(html);
Assert.AreEqual(true, parser.Parse());
Assert.IsNotNull(parser.Current);
parser.Current.AnalyzeNode("input", html, html, null, true, false, 0, 0, 0);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:10,代码来源:InvalidHtml.cs
示例18: InvalidQuote
public void InvalidQuote()
{
string html = "<div style=\"width:100%\" \">test</div>";
HtmlParser parser = new HtmlTextParser(html);
Assert.AreEqual(true, parser.Parse());
parser.ParseStyles();
Assert.IsNotNull(parser.Current);
parser.Current.AnalyzeNode("div", "test", html, null, false, true, 1, 1, 1);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:11,代码来源:InvalidHtml.cs
示例19: InvalidInputAttribute
public void InvalidInputAttribute()
{
string html = "<input =\"\" name=\"fld_quicksign\">";
HtmlParser parser = new HtmlTextParser(html);
Assert.AreEqual(true, parser.Parse());
Assert.IsNotNull(parser.Current);
Assert.AreEqual(1, parser.Current.Attributes.Count);
TestUtility.CheckKeyValuePair(parser.Current.Attributes.ElementAt(0), "name", "fld_quicksign");
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:11,代码来源:InvalidHtml.cs
示例20: EmptyHtml
public void EmptyHtml()
{
string html = " ";
HtmlParser parser = new HtmlTextParser(html);
Assert.IsTrue(parser.Parse());
Assert.IsNotNull(parser.Current);
TestUtility.AreEqual(parser.Current, "#text", html, html);
Assert.IsNull(parser.Current.Previous);
Assert.IsNull(parser.Current.Next);
}
开发者ID:kannan-ar,项目名称:MariGold.HtmlParser,代码行数:12,代码来源:ParseMethod.cs
注:本文中的MariGold.HtmlParser.HtmlTextParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论