Esempio n. 1
0
 private static HtmlNode PopCurrentNodeParentIfCurrentNodeIsEmptyTag(Stack<HtmlNode> stack, HtmlNode currentNode)
 {
     HtmlElementFlag elementFlag;
     string key = currentNode.Name ?? string.Empty;
     elementsFlags.TryGetValue(key.ToLower(), out elementFlag);
     if (elementFlag == HtmlElementFlag.Empty)
         currentNode = stack.Pop();
     return currentNode;
 }
Esempio n. 2
0
 /// <summary>
 /// This will return true if the node passed is a descendant of this nodes.
 /// </summary>
 /// <param attributeName="nodes">The nodes that might be the parent or grandparent (etc.)</param>
 /// <returns>True if this nodes is a descendant of the one passed in.</returns>
 public bool IsDescendantOf(HtmlNode node)
 {
     HtmlNode current = this.parent;
     while (current != null)
     {
         if( current == node )
         {
             return true;
         }
         current = current.Parent;
     }
     return false;
 }
Esempio n. 3
0
 /// <summary>
 /// This will return true if the node passed is one of the children or grandchildren of this nodes.
 /// </summary>
 /// <param attributeName="nodes">The nodes that might be a child.</param>
 /// <returns>True if this nodes is an ancestor of the one specified.</returns>
 public bool IsAncestorOf(HtmlNode node)
 {
     if (null != node)
         return node.IsDescendantOf(this);
     else
         return false;
 }
Esempio n. 4
0
        /// <summary>
        /// This will return the ancestor that is common to this nodes and the one specified.
        /// </summary>
        /// <param attributeName="nodes">The possible nodes that is relative</param>
        /// <returns>The common ancestor, or null if there is none</returns>
        public HtmlNode GetCommonAncestor(HtmlNode node)
        {
            HtmlNode current = this;

            while (node != null)
            {
                if (this.IsDescendantOf(node))
                {
                    return node;
                }
                node = node.Parent;
            }
            return null;
        }
Esempio n. 5
0
        public void AppendChild(HtmlNode node)
        {
            if (FirstChild == null)
                FirstChild = node;

            node.PreviousSibling = LastChild;

            if (LastChild != null)
                LastChild.NextSibling = node;

            LastChild = node;

            node.ParentNode = this;

            childNodes.Add(node);
        }
Esempio n. 6
0
 public void AppendAttribute(HtmlNode attribute)
 {
     attributes.Add(attribute);
 }