可以在xml中靠增加属性来实现分组

可以在一篇xml文档中,靠增加一个行的属性,来进行排序。
有这方面需求的folks,请参考如下代码:
 private void UniteHtmlCell(ref XmlDocument xDocument)
        {
            int rowsCount = xDocument.DocumentElement.ChildNodes.Count;//xml文档的行数
            for (int i = 0; i < rowsCount; i++)
            {
                string rowgroup = i.ToString();
                XmlNode rowi = xDocument.DocumentElement.ChildNodes[i];//i行的TestCategory级别
                XmlNode sub_rowi = rowi.FirstChild;//Test级别
                XmlNode ssub_rowi = sub_rowi.FirstChild;//result级别
                XmlElement xe1 = (XmlElement)ssub_rowi;
                //label1.Text = xe1.GetAttribute("buginfo");
                if (xe1.GetAttribute("buginfo") != "" && xe1.GetAttribute("buginfo") != "-")
                {
                    int groupRowsCount = 1;
                    xe1.SetAttribute("rowgroup", rowgroup);
                    for (int j = i + 1; j < rowsCount; j++)
                    {
                        XmlNode rowj = xDocument.DocumentElement.ChildNodes[j];//j行的TestCategory级别
                        XmlNode sub_rowj = rowj.FirstChild;//Test级别
                        XmlNode ssub_rowj = sub_rowj.FirstChild;//result级别
                        XmlElement xe2 = (XmlElement)ssub_rowj;
                        if (xe1.GetAttribute("buginfo") == xe2.GetAttribute("buginfo").ToString())
                        {
                            groupRowsCount++;
                            XmlElement xe = (XmlElement)ssub_rowj;
                            xe.SetAttribute("buginfo", "");//靠这个属性来
                            xe.SetAttribute("rowgroup", rowgroup);
                        }
                     }
                    //在具有相同buginfo的result级别添加属性groupRowsCount,这样就可以在xslt(已经按照buginfo排序)文件中实现单元格的合并
                    string grCount = groupRowsCount.ToString();
                    XmlElement xe3 = (XmlElement)ssub_rowi;
                    xe3.SetAttribute("groupRowsCount", grCount);
                }
             }
        }

转载于:https://www.cnblogs.com/pojianhuadie/archive/2006/05/23/407224.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值