private HtmlInstruction createInstructions(HtmlItem item) { if (item == null) { return(null); } //if (nextInstruction != null) //{ // HtmlInstruction instruction = HtmlInstruction.CreateGetNextItem(item.Type, null); // instruction.Next = nextInstruction; // return instruction; //} do { //if this is our end point HtmlInstruction nextInstruction = Found(item); if (nextInstruction == null) { nextInstruction = createInstructions(item.Next(HtmlItem.NextType.Down)); } if (nextInstruction != null) { Dictionary <string, string> attributes = null; if (UseAttributeKeys && item.Attributes.Count > 0) { if (UseAttributeValues) { attributes = copyAttributesWithValues(item); } else { attributes = copyAttributeKeys(item); } } HtmlInstruction instruction = HtmlInstruction.CreateGetNextItem(item.Type, attributes); instruction.Next = nextInstruction; return(instruction); } } while ((item = item.Next(HtmlItem.NextType.SameLevel)) != null); return(null); }
public LinkedList <HtmlItem> GetRange(string type, Dictionary <string, string> attributes) { HtmlItem stop = Next(false); HtmlItem item = this; LinkedList <HtmlItem> list = new LinkedList <HtmlItem>(); while ((item = item.Next()) != stop) { if (item.IsType(type) && item.HasAttributes(attributes)) { list.AddLast(item); } } return(list); }
/// <summary> /// /// </summary> /// <param name="fromStart">This would be the top item like the "p" item from the search results.</param> /// <returns></returns> public HtmlInstruction CreateInstructions(HtmlItem fromStart) { return(createInstructions(fromStart.Next(HtmlItem.NextType.Down))); }