/// <summary> /// Returns a list of elements with the given tag name belonging to the given namespace. /// The complete document is searched, including the root node. /// </summary> /// <param name="namespaceURI">The namespace URI of elements to look for.</param> /// <param name="localName">Either the local name of elements to look for or the special value "*", which matches all elements.</param> /// <returns>A NodeList of found elements in the order they appear in the tree.</returns> internal HTMLCollection GetElementsByTagNameNS(String namespaceURI, String localName) { var result = new HTMLCollection(); GetElementsByTagNameNS(this, namespaceURI, localName, result); return(result); }
/// <summary> /// Returns a list of the elements within the document (using depth-first pre-order traversal /// of the document's nodes) that matches the selector. /// </summary> /// <param name="selector">A selector object.</param> /// <returns>A HTMLCollection with all elements that match the selection.</returns> internal HTMLCollection QuerySelectorAll(Selector selector) { var result = new HTMLCollection(); QuerySelectorAll(this, selector, result); return(result); }
/// <summary> /// Returns a NodeList of elements with the given tag name. The complete document is searched, including the root node. /// </summary> /// <param name="tagName">A string representing the name of the elements. The special string "*" represents all elements.</param> /// <returns>A NodeList of found elements in the order they appear in the tree.</returns> internal HTMLCollection GetElementsByTagName(String tagName) { var result = new HTMLCollection(); GetElementsByTagName(this, tagName, result); return(result); }
/// <summary> /// Returns a list of the elements within the document (using depth-first pre-order traversal /// of the document's nodes) that match the specified group of selectors. /// </summary> /// <param name="selectors">A string containing one or more CSS selectors separated by commas.</param> /// <returns>A HTMLCollection with all elements that match the selection.</returns> internal HTMLCollection QuerySelectorAll(String selectors) { var sg = CssParser.ParseSelector(selectors); var result = new HTMLCollection(); QuerySelectorAll(this, sg, result); return(result); }
/// <summary> /// Returns a NodeList of elements with the given tag name. The complete document is searched, including the root node. /// </summary> /// <param name="tagName">A string representing the name of the elements. The special string "*" represents all elements.</param> /// <returns>A NodeList of found elements in the order they appear in the tree.</returns> internal HTMLCollection GetElementsByTagName(String tagName) { var result = new HTMLCollection(); var takeAll = tagName == "*"; GetElementsByTagName(this, tagName, result, takeAll); return(result); }
/// <summary> /// Returns a set of elements which have all the given class names. /// </summary> /// <param name="classNames">A string representing the list of class names to match; class names are separated by whitespace.</param> /// <returns>A collection of HTML elements.</returns> internal HTMLCollection GetElementsByClassName(String classNames) { var result = new HTMLCollection(); var names = classNames.SplitSpaces(); if (names.Length > 0) { GetElementsByClassName(this, names, result); } return(result); }
static void GetElementsByClassName(NodeList elements, string[] classNames, HTMLCollection result) { for (int i = 0; i < elements.Length; i++) { var element = elements[i] as HTMLElement; if (element != null) { if (element.ClassList.Contains(classNames)) { result.Add(element); } if (element.ChildElementCount != 0) { GetElementsByClassName(element.ChildNodes, classNames, result); } } } }
static void QuerySelectorAll(NodeList elements, Selector selector, HTMLCollection result) { for (int i = 0; i < elements.Length; i++) { var element = elements[i] as Element; if (element != null) { if (selector.Match(element)) { result.Add(element); } if (element.HasChildNodes) { QuerySelectorAll(element.ChildNodes, selector, result); } } } }
static void GetElementsByTagName(NodeList elements, String tagName, HTMLCollection result, Boolean takeAll) { for (int i = 0; i < elements.Length; i++) { var element = elements[i] as Element; if (element != null) { if (takeAll || element.NodeName.Equals(tagName, StringComparison.OrdinalIgnoreCase)) { result.Add(element); } if (element.ChildElementCount != 0) { GetElementsByTagName(element.ChildNodes, tagName, result, takeAll); } } } }
public virtual Object NamedItem(String id) { var result = new HTMLCollection(); for (int i = 0; i < _entries.Count; i++) { if (_entries[i].Id == id) { result.Add(_entries[i]); } } if (result.Length == 1) { return(result[0]); } else if (result.Length != 0) { return(result); } for (int i = 0; i < _entries.Count; i++) { if (_entries[i].GetAttribute("name") == id) { result.Add(_entries[i]); } } if (result.Length == 1) { return(result[0]); } else if (result.Length != 0) { return(result); } return(null); }
static void GetElementsByTagNameNS(NodeList elements, string namespaceURI, string localName, HTMLCollection result) { var takeAll = localName == "*"; for (int i = 0; i < elements.Length; i++) { var element = elements[i] as Element; if (element != null) { if (element.NamespaceURI == namespaceURI && (takeAll || element.LocalName.Equals(localName, StringComparison.OrdinalIgnoreCase))) { result.Add(element); } if (element.ChildElementCount != 0) { GetElementsByTagNameNS(element.ChildNodes, namespaceURI, localName, result); } } } }