Ejemplo n.º 1
0
 internal static ToxyNode TransformHtmlNodeToToxyNode(HtmlAgilityPack.HtmlNode htmlNode)
 {
     if (htmlNode == null)
     {
         return null;
     }
     ToxyNode toxyNode = new ToxyNode();
     toxyNode.Name = htmlNode.Name;
     foreach (var item in htmlNode.Attributes)
     {
         toxyNode.Attributes.Add(new ToxyAttribute { Name = item.Name, Value = item.Value });
     }
     toxyNode.HtmlNode = htmlNode;
     return toxyNode;
 }
Ejemplo n.º 2
0
        public List <ToxyNode> SelectNodes(string selector)
        {
            HtmlAgilityPack.HtmlNodeCollection htmlNodeList = this.HtmlNode.SelectNodes(selector);
            if (htmlNodeList == null)
            {
                return(null);
            }

            List <ToxyNode> toxyNodeList = new List <ToxyNode>();

            foreach (var item in htmlNodeList)
            {
                //todo:need to copy ChildNodes to the seleted node
                toxyNodeList.Add(ToxyNode.TransformHtmlNodeToToxyNode(item));
            }
            return(toxyNodeList);
        }
Ejemplo n.º 3
0
        internal static ToxyNode TransformHtmlNodeToToxyNode(HtmlAgilityPack.HtmlNode htmlNode)
        {
            if (htmlNode == null)
            {
                return(null);
            }
            ToxyNode toxyNode = new ToxyNode();

            toxyNode.Name = htmlNode.Name;
            foreach (var item in htmlNode.Attributes)
            {
                toxyNode.Attributes.Add(new ToxyAttribute {
                    Name = item.Name, Value = item.Value
                });
            }
            toxyNode.HtmlNode = htmlNode;
            return(toxyNode);
        }
Ejemplo n.º 4
0
 void AppendTree(TreeNode node, ToxyNode tnode)
 { 
    if(tnode.ChildrenNodes==null||tnode.ChildrenNodes.Count==0)
        return;
    foreach (var child in tnode.ChildrenNodes)
    {
        TreeNode childNode ;
        if(child.Name=="#text")
            childNode = node.Nodes.Add(child.Text);
        else
             childNode = node.Nodes.Add(child.NodeString);
        AppendTree(childNode, child);
    }
 }
Ejemplo n.º 5
0
 public ToxyNode SingleSelect(string selector)
 {
     //todo:need to copy ChildNodes to the seleted node
     return(ToxyNode.TransformHtmlNodeToToxyNode(this.HtmlNode.SelectSingleNode(selector)));
 }