可以在xml中靠增加属性来实现分组
可以在一篇xml文檔中,靠增加一個行的屬性,來進(jìn)行排序。
有這方面需求的folks,請參考如下代碼:
?private void UniteHtmlCell(ref XmlDocument xDocument)
??????? {
??????????? int rowsCount = xDocument.DocumentElement.ChildNodes.Count;//xml文檔的行數(shù)
??????????? 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(已經(jīng)按照buginfo排序)文件中實(shí)現(xiàn)單元格的合并
??????????????????? string grCount = groupRowsCount.ToString();
??????????????????? XmlElement xe3 = (XmlElement)ssub_rowi;
??????????????????? xe3.SetAttribute("groupRowsCount", grCount);
??????????????? }
???????????? }
??????? }
轉(zhuǎn)載于:https://www.cnblogs.com/pojianhuadie/archive/2006/05/23/407224.html
總結(jié)
以上是生活随笔為你收集整理的可以在xml中靠增加属性来实现分组的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 男主角禁欲系大PK 林更新赵又廷哪个更迷
- 下一篇: 树脂补牙多少钱一颗啊?