Example #1
0
        /// <summary>
        /// Returns the first element within the document (using depth-first pre-order traversal
        /// of the document's nodes) that matches the specified group of selectors.
        /// </summary>
        /// <param name="elements">The elements to take as source.</param>
        /// <param name="selectors">A string containing one or more CSS selectors separated by commas.</param>
        /// <returns>An element object.</returns>
        public static IElement QuerySelector(this INodeList elements, String selectors)
        {
            var sg = CssParser.Default.ParseSelector(selectors);

            Validate(sg);
            return(elements.QuerySelector(sg));
        }
 /// <summary>
 /// Returns the first element within this element (using depth-first pre-order traversal
 /// of the document's nodes) that matches the specified group of selectors.
 /// </summary>
 /// <param name="selector">The group of selectors to use.</param>
 /// <param name="nodelist">The elements to search within</param>
 public static IElement Find(this INodeList nodelist, string selector)
 {
     if (nodelist is null)
     {
         throw new ArgumentNullException(nameof(nodelist));
     }
     return(nodelist.QuerySelector(selector));
 }
Example #3
0
        /// <summary>
        /// Returns the first element within the document (using depth-first pre-order traversal
        /// of the document's nodes) that matches the specified group of selectors.
        /// </summary>
        /// <param name="elements">The elements to take as source.</param>
        /// <param name="selectors">A string containing one or more CSS selectors separated by commas.</param>
        /// <returns>An element object.</returns>
        public static IElement QuerySelector(this INodeList elements, String selectors)
        {
            var sg = CssParser.ParseSelector(selectors);

            if (sg == null)
            {
                throw new DomException(ErrorCode.Syntax);
            }

            return(elements.QuerySelector(sg));
        }
Example #4
0
        public static IElement QuerySelector(this INodeList elements, string selectors, CssParser parser)
        {
            var selector = parser.ParseSelector(selectors);

            if (selector == null)
            {
                throw new DomException(DomError.Syntax);
            }

            return(elements.QuerySelector(selector));
        }
Example #5
0
 /// <summary>
 /// Returns the first element within the document (using depth-first pre-order traversal
 /// of the document's nodes) that matches the given selector.
 /// </summary>
 /// <param name="elements">The elements to take as source.</param>
 /// <param name="selectors">A selector object.</param>
 /// <returns>An element object.</returns>
 public static T QuerySelector <T>(this INodeList elements, ISelector selectors)
     where T : class, IElement
 {
     return(elements.QuerySelector(selectors) as T);
 }