// ------------------------------------------------------------------ /// <summary> /// Does the extract links. /// </summary> /// <param name="xml">The XML.</param> /// <param name="uriInfo">The URI info.</param> /// <returns></returns> private List<UriResourceInformation> DoExtractLinks( XmlReader xml, UriResourceInformation uriInfo) { //Resulting resource list. List<UriResourceInformation> links = new List<UriResourceInformation>(); //Loop through the HTML doc as Xml. while (xml.Read()) { //Do something based on the element type. switch (xml.NodeType) { //Grab inside comments, too. case XmlNodeType.Comment: XmlReader childXml = GetDocReader(xml.Value, uriInfo.BaseUri); //Grab links inside the comments List<UriResourceInformation> childLinks = DoExtractLinks(childXml, uriInfo); links.AddRange(childLinks); break; // An HTML node element. case XmlNodeType.Element: //Temp link attributes holder. string[] linkAttributeNames; //Link types. UriType linkType; // If this is a link element(A, FORM, APPLET, REL), proceed to store the URLs to modify. if (IsLinkElement( xml.Name, out linkAttributeNames, out linkType)) { //Loop through all the elements in the element. while (xml.MoveToNextAttribute()) { //Loop through each attribute of this (A, FORM, APPLET, REL) element. foreach (string a in linkAttributeNames) { //If the resource attribute matches, then add it. if (string.Compare(a, xml.Name, true) == 0) { string url = xml.Value; if (xml.Value.Contains("get_bill_text.asp")) { string sdfa = "Stop"; } if (xml.Value.Contains("get_fulltext.asp")) { string adf = @"Stop"; } //Save the Resource information UriResourceInformation ui = null; //Flag resource as a form. if (xml.Name == @"action") linkType = UriType.Form; //Create link ui = new UriResourceInformation( _settings.Options, url, new Uri(url, UriKind.RelativeOrAbsolute), uriInfo.BaseUriWithFolder, linkType, uriInfo.AbsoluteUri, uriInfo.Index); //Is in same domain bool isOnSameSite = ui.IsOnSameSite(uriInfo.BaseUri); //Stay on Site, and is processable. if ((isOnSameSite || !_settings.Options.StayOnSite) && ui.IsProcessableUri) { //Check to see if the link points to current session of legis if (ui.OriginalUrl.Contains(String.Format("session={0}", _settings.Options.TargetSession))) { //Add the resource. links.Add(ui); } } } } } } else { // Also, look for style attributes. //while (xml.MoveToNextAttribute()) //{ // links.AddRange( // ExtractStyleUrls( // uriInfo.BaseUriWithFolder, // xml.Name, // xml.Value)); //} } break; } } if (links.ToArray().Length > 0) { string stp = @"stop"; } return links; }