/// <summary> /// This will insert a node at the given position /// </summary> /// <param name="index">The position at which to insert the node.</param> /// <param name="node">The node to insert.</param> public void Insert(int index,HtmlNode node) { if( mParent != null ) node.SetParent( mParent ); base.InnerList.Insert( index , node ); }
/// <summary> /// This is used to identify the index of this node as it appears in the collection. /// </summary> /// <param name="node">The node to test</param> /// <returns>The index of the node, or -1 if it is not in this collection</returns> public int IndexOf(HtmlNode node) { return base.List.IndexOf( node ); }
/// <summary> /// This will add a node to the collection. /// </summary> /// <param name="node"></param> /// <returns></returns> public int Add(HtmlNode node) { if( mParent != null ) node.SetParent( mParent ); return base.List.Add( node ); }
public bool IsDescendentOf(HtmlNode node) { HtmlNode parent = mParent; while( parent != null ) { if( parent == node ) { return true; } parent = parent.Parent; } return false; }
public bool IsAncestorOf(HtmlNode node) { return node.IsDescendentOf( this ); }
public HtmlNode GetCommonAncestor(HtmlNode node) { HtmlNode thisParent = this; while( thisParent != null ) { HtmlNode thatParent = node; while( thatParent != null ) { if( thisParent == thatParent ) { return thisParent; } thatParent = thatParent.Parent; } thisParent = thisParent.Parent; } return null; }