示例#1
0
        void Trace(HtmlNode node, opis rn, bool ignoreattr = false)
        {
            rn.ReinitArr(node.ChildNodes.Count + 2);
            //  rn.ArrResize(node.ChildNodes.Count + 2);

            rn[0] = new opis(node.Attributes.Count + 3)
            {
                PartitionName = "Attributes"
            };

            foreach (var a in node.Attributes)
            {
                rn[0].Vset(a.Name, a.Value);
            }

            if (!ignoreattr && (namesAtrIgnore == null || !namesAtrIgnore.Contains(node.Name)))
            {
                var htmobj = rn[0]["InnerHtml"];

                if (maxHtmlShow != 0)
                {
                    var html = "";

                    try
                    {
                        html = node.InnerHtml;
                    }
                    catch (ArgumentOutOfRangeException e)
                    {
                        html = "";
                    }

                    if (html.Length < maxHtmlShow)
                    {
                        htmobj.body = normalize_spaces.NormalizeSpRemoveControlsSeparators(html);
                    }

                    //htmobj.body = html.Trim()
                    //                                .Replace('\n', ' ')
                    //                                .Replace('\t', ' ');
                }

                rn[0].Vset("InnerText", normalize_spaces.NormalizeSpRemoveControlsSeparators(node.InnerText));

                //rn[0].Vset("InnerText", node.InnerText.Trim().Replace("\n", " ")
                //                                    .Replace("\t", " ").Replace("                ", " ").Replace("     ", " "));
            }
            else
            {
                ignoreattr = !ignoreattr;
            }


            foreach (var n in node.ChildNodes)
            {
                if (n.Name != "#text")
                {
                    opis cn = new opis(-1);
                    cn.PartitionName = n.Name;
                    //cn.PartitionKind = "";
                    //cn.body = "";


                    rn.AddArr(cn);
                    Trace(n, cn, ignoreattr);
                }
            }
        }