Exemple #1
0
        /// <summary>Searches a document for any sub-documents (inside iframes).</summary>
        public static void Search(Document doc, string name, List <DocumentEntry> results)
        {
            if (doc == null)
            {
                return;
            }

            // Add it:
            results.Add(new DocumentEntry(doc, name));

            // Search for iframe's:
            Dom.HTMLCollection set = doc.getElementsByTagName("iframe");

            foreach (Element node in set)
            {
                // Get as a HTML element:
                HtmlElement htmlElement = node as HtmlElement;

                // Double check it's not some evil iframe twin:
                if (htmlElement != null)
                {
                    string src = htmlElement["src"];

                    // Search content doc:
                    Search(htmlElement.contentDocument, src, results);
                }
            }
        }
        /// <summary>Searches a document for any sub-documents (inside iframes).</summary>
        public static Document SearchForID(Document doc, uint id)
        {
            if (doc == null)
            {
                return(null);
            }

            if (doc.uniqueID == id)
            {
                return(doc);
            }

            // Search for iframe's:
            Dom.HTMLCollection set = doc.getElementsByTagName("iframe");

            foreach (Element node in set)
            {
                // Get as a HTML element:
                HtmlElement htmlElement = node as HtmlElement;

                // Double check it's not some evil iframe twin:
                if (htmlElement != null)
                {
                    // Search content doc:
                    Document result = SearchForID(htmlElement.contentDocument, id);

                    if (result != null)
                    {
                        return(result);
                    }
                }
            }

            return(null);
        }