本文整理汇总了C#中HtmlAgilityPack.HtmlNode.GetParentOfType方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlNode.GetParentOfType方法的具体用法?C# HtmlNode.GetParentOfType怎么用?C# HtmlNode.GetParentOfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlAgilityPack.HtmlNode
的用法示例。
在下文中一共展示了HtmlNode.GetParentOfType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadFromHtml
public bool LoadFromHtml(HtmlNode rootNode, bool loggedIn)
{
if (rootNode.Name != "a")
{
return false;
}
if (!base.LoadFromLinkNode(rootNode))
{
return false;
}
if (!IsTopicUrl(Url))
{
return false;
}
HtmlNode pTD = rootNode.GetParentOfType("td");
HtmlNode prevTD = pTD.GetPrevSiblingOfType("td");
HtmlNode prevTD2 = prevTD.GetPrevSiblingOfType("td");
HtmlNode nextTD = pTD.GetNextSiblingOfType("td");
String prevText = HtmlUtilities.GetPlainHtmlText(prevTD.InnerText).Trim();
IsOnTop = (prevText == "提示");
if (!prevText.Contains("*"))
{
IsRead = true;
}
else
{
IsRead = false;
}
if (prevText.Contains("@"))
{
HasImage = true;
}
else
{
HasImage = false;
}
if (prevText.Contains("m"))
{
MFlag = true;
IsRead = true;
}
else if (prevText.Contains("M"))
{
MFlag = true;
IsRead = false;
}
else
{
MFlag = false;
}
if (prevText.Contains("b"))
{
BFlag = true;
IsRead = true;
}
else if (prevText.Contains("B"))
{
BFlag = true;
IsRead = false;
}
else
{
BFlag = false;
}
if (prevText.Contains("g"))
{
GFlag = true;
IsRead = true;
}
else if (prevText.Contains("G"))
{
GFlag = true;
IsRead = false;
}
else
{
GFlag = false;
}
if (IsOnTop || !App.Settings.KeepHistory || !App.WebSession.IsLoggedIn || !loggedIn)
{
IsRead = false;
}
ReplyCount = null;
Author = null;
foreach (HtmlNode authorNode in nextTD.Descendants("a"))
{
Author = HtmlUtilities.GetPlainHtmlText(authorNode.InnerText).Trim();
break;
}
//.........这里部分代码省略.........
示例2: LoadFromHtml
//.........这里部分代码省略.........
}
}
else if (node.Name == "img")
{
if (node.ParentNode.Name == "a")
{
continue;
}
}
contentBlock = ContentBlock.CreateContentBlockFromHtml(node, ParentUrl);
}
if (contentBlock != null)
{
bool isSignatureStart = false;
if (text == "--")
{
hasQuote = false;
isSignatureStart = true;
contentBlock.NoMerge = true;
}
if (prevContentBlock != null && SignatureStart >= 0 && contentBlock is TextContentBlock && (contentBlock as TextContentBlock).Text == "\n")
{
prevContentBlock.NoMerge = true;
}
if ((prevContentBlock == null) || !(prevContentBlock.MergeWith(contentBlock)))
{
if (!hasQuote || !(contentBlock is QuoteBlock) || !App.Settings.HideFullQuote)
{
Contents.Add(contentBlock);
prevContentBlock = contentBlock;
if (prevContentBlock != null)
{
if (prevContentBlock is QuoteBlock)
{
hasQuote = true;
}
}
if (isSignatureStart)
{
_signatureLastPos = SignatureStart;
SignatureStart = Contents.Count - 1;
}
}
}
}
}
if (_signatureLastPos >= 0)
{
SignatureStart = _signatureLastPos;
}
HtmlNode pTable = RootNode.GetParentOfType("table");
HtmlNode prevTable = pTable.GetPrevSiblingOfType("table");
if (prevTable != null)
{
foreach (HtmlNode linkNode in prevTable.Descendants("a"))
{
String linkText = linkNode.GetLinkText();
String linkUrl = linkNode.GetLinkUrl(ParentUrl);
if (linkText == "本篇全文")
{
PostUrl = linkUrl;
}
else if (linkText == "回复")
{
ReplyPostUrl = linkUrl;
}
else if (linkText == "修改")
{
ModifyPostUrl = linkUrl;
}
else if (linkText == "删除")
{
if (linkNode.Attributes.Contains("onclick"))
{
DeletePostUrl = linkNode.Attributes["onclick"].Value;
}
}
else if (linkText == "转贴")
{
ForwardUrl = linkUrl;
}
}
}
}
catch (Exception)
{
return false;
}
return true;
}