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; }
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); }
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); }
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); } }
public ToxyNode SingleSelect(string selector) { //todo:need to copy ChildNodes to the seleted node return(ToxyNode.TransformHtmlNodeToToxyNode(this.HtmlNode.SelectSingleNode(selector))); }