本文整理汇总了C#中IHtmlElement.Find方法的典型用法代码示例。如果您正苦于以下问题:C# IHtmlElement.Find方法的具体用法?C# IHtmlElement.Find怎么用?C# IHtmlElement.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHtmlElement
的用法示例。
在下文中一共展示了IHtmlElement.Find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HtmlSelect
internal HtmlSelect( HtmlForm form, IHtmlElement element )
: base( form )
{
Element = element;
options = element.Find( "option" ).Select( e => new HtmlOption( this, e ) ).ToArray();
}
示例2: HtmlSelect
public HtmlSelect( HtmlForm form, IHtmlElement element )
{
if ( !element.Name.EqualsIgnoreCase( "select" ) )
throw new InvalidOperationException();
_form = form;
_element = element;
options = element.Find( "option" ).Select( e => new HtmlOption( this, e ) ).ToArray();
}
示例3: MergeHead
/// <summary>
/// 合并内容视图与母板视图的文档头
/// </summary>
/// <param name="masterHead">母板视图的文档头</param>
/// <param name="contentHead">内容视图的文档头</param>
/// <returns>合并后的 <head> 元素</returns>
protected virtual IHtmlElement MergeHead( IHtmlElement masterHead, IHtmlElement contentHead )
{
var head = masterHead.Document.CreateFragment().AddElement( "head" );
head.AddCopy( contentHead.Elements().Where( e => e.Attribute( "ignore" ) == null ) );
if ( !head.Find( "title" ).Any() )
{
var title = masterHead.Find( "title" ).FirstOrDefault();
head.AddCopy( title );
}
{
var existsStyleSheets = new HashSet<string>( head.Find( "link[rel=stylesheet]" ).Select( e => e.Attribute( "href" ).Value() ), StringComparer.OrdinalIgnoreCase );
foreach ( var element in masterHead.Find( "link[rel=stylesheet]" ) )
{
if ( !existsStyleSheets.Contains( element.Attribute( "href" ).Value() ) )
head.AddCopy( element );
}
}
{
var existsScripts = new HashSet<string>( head.Find( "script[src]" ).Select( e => e.Attribute( "src" ).Value() ), StringComparer.OrdinalIgnoreCase );
foreach ( var element in masterHead.Find( "script[src]" ) )
{
if ( !existsScripts.Contains( element.Attribute( "src" ).Value() ) )
head.AddCopy( element );
}
}
return head;
}