本文整理汇总了C#中Element.TagName方法的典型用法代码示例。如果您正苦于以下问题:C# Element.TagName方法的具体用法?C# Element.TagName怎么用?C# Element.TagName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element.TagName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseFragment
public IList<Node> ParseFragment(string inputFragment, Element context, string baseUri, ParseErrorList errors)
{
// context may be null
_state = HtmlTreeBuilderState.Initial;
InitialiseParse(inputFragment, baseUri, errors);
_contextElement = context;
_fragmentParsing = true;
Element root = null;
if (context != null)
{
if (context.OwnerDocument != null) // quirks setup:
{
_doc.QuirksMode(context.OwnerDocument.QuirksMode());
}
// initialise the tokeniser state:
string contextTag = context.TagName();
if (StringUtil.In(contextTag, "title", "textarea"))
{
_tokeniser.Transition(TokeniserState.RcData);
}
else if (StringUtil.In(contextTag, "iframe", "noembed", "noframes", "style", "xmp"))
{
_tokeniser.Transition(TokeniserState.RawText);
}
else if (contextTag.Equals("script"))
{
_tokeniser.Transition(TokeniserState.ScriptData);
}
else if (contextTag.Equals(("noscript")))
{
_tokeniser.Transition(TokeniserState.Data); // if scripting enabled, rawtext
}
else if (contextTag.Equals("plaintext"))
{
_tokeniser.Transition(TokeniserState.Data);
}
else
{
_tokeniser.Transition(TokeniserState.Data); // default
}
root = new Element(Tag.ValueOf("html"), baseUri);
_doc.AppendChild(root);
_stack.AddFirst(root);
ResetInsertionMode();
// todo: setup form element to nearest form on context (up ancestor chain)
}
RunParser();
if (context != null)
{
return root.ChildNodes;
}
else
{
return _doc.ChildNodes;
}
}
示例2: Matches
public override bool Matches(Element root, Element element)
{
return (element.TagName().Equals(tagName));
}
示例3: CreateSafeElement
private ElementMeta CreateSafeElement(Element sourceEl)
{
string sourceTag = sourceEl.TagName();
Attributes destAttrs = new Attributes();
Element dest = new Element(Tag.ValueOf(sourceTag), sourceEl.BaseUri, destAttrs);
int numDiscarded = 0;
Attributes sourceAttrs = sourceEl.Attributes;
foreach (NSoup.Nodes.Attribute sourceAttr in sourceAttrs)
{
if (_whitelist.IsSafeAttribute(sourceTag, sourceEl, sourceAttr))
destAttrs.Add(sourceAttr);
else
numDiscarded++;
}
Attributes enforcedAttrs = _whitelist.GetEnforcedAttributes(sourceTag);
foreach (NSoup.Nodes.Attribute item in enforcedAttrs)
{
destAttrs.Add(item);
}
return new ElementMeta(dest, numDiscarded);
}