且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无效的xml ...使用C#生成融合图时出现问题

更新时间:2023-02-15 07:53:51

); Chart.DocumentElement.SetAttribute("pieSliceDepth","30"); Chart.DocumentElement.SetAttribute("startingAngle","125"); Chart.DocumentElement.SetAttribute("showValues","0"); XmlDocument LossTimeXml =新的XmlDocument(); XmlDocument TotalTimeXml =新的XmlDocument(); //string fmdt = Request.QueryString ["FromDate"].ToString(); //string tdt = Request.QueryString ["ToDate"].ToString(); //string did = Request.QueryString ["did"].ToString(); double lt,tt,结果; 字符串st = DAL.GenericSP_Str(2,"Sp_GetTruckTrackingPieChart",< Root FromDate = \""+ Request.QueryString [" FromDate] +" \"Todate = \""+ Request.QueryString [" ToDate] + "\"/>); LossTimeXml.LoadXml(st); 字符串slt = Convert.ToString(LossTimeXml.DocumentElement.GetAttribute("value"))); 字符串stt = Convert.ToString(LossTimeXml.DocumentElement.GetAttribute("TotalVehicles")); lt = Convert.ToDouble(slt); tt = Convert.ToDouble(stt); 结果=(lt/tt)* 100; XmlElement ActiveElement = Chart.CreateElement("set"); ActiveElement.SetAttribute("label","Active" +(" + lt +)" +"[" + Math.Round(result,2)+%]"); ActiveElement.SetAttribute("value",Math.Round(result,2).ToString()); ActiveElement.SetAttribute("link","P-detailsPopUp,width = 800,height = 550,toolbar = no,scrollbars = no,resizable = no-TruckDailyChart.aspx?FromDate =" + Request.QueryString ["FromDate"] + & ToDate =" + Request.QueryString ["ToDate"] +& Status =" +"1" +& label = Active"); Chart.DocumentElement.AppendChild(ActiveElement); TotalTimeXml.LoadXml(DAL.GenericSP_Str(2,"Sp_GetTruckTrackingPieChartInActive",&Root FromDate = \""+ Request.QueryString [" FromDate] +" \"Todate = \""+ Request.QueryString [" ToDate] +"\"/>))); lt = Convert.ToDouble(TotalTimeXml.DocumentElement.GetAttribute("value")); tt = Convert.ToDouble(TotalTimeXml.DocumentElement.GetAttribute("TotalVehicles")); 结果=(lt/tt)* 100; XmlElement InActiveElement = Chart.CreateElement("set"); InActiveElement.SetAttribute("label","InActive" +(" + lt +)" +"[" + Math.Round(result,2)+%]"); InActiveElement.SetAttribute("value",Math.Round(result,2).ToString()); InActiveElement.SetAttribute("link","P-detailsPopUp,width = 800,height = 550,toolbar = no,scrollbars = no,resizable = no-TruckDailyChart.aspx?FromDate =" + Request.QueryString ["FromDate"] + & ToDate =" + Request.QueryString ["ToDate"] +& Status =" +"2" +& label =无效")); Chart.DocumentElement.AppendChild(InActiveElement); XmlElement Style = Chart.CreateElement("styles"); XmlElement定义= Chart.CreateElement("definition"); Style.AppendChild(definition); XmlElement style1 = Chart.CreateElement("style"); style1.SetAttribute("type","font"); style1.SetAttribute("name","CaptionFont"); style1.SetAttribute("size","15"); style1.SetAttribute("color","666666"); XmlElement style2 = Chart.CreateElement("style"); style2.SetAttribute("type","font"); style2.SetAttribute("name","SubCaptionFont"); style2.SetAttribute("bold","1"); definition.AppendChild(style1); definition.AppendChild(style2); XmlElement application = Chart.CreateElement("application"); Style.AppendChild(应用程序); XmlElement apply1 = Chart.CreateElement("style"); apply1.SetAttribute("toObject",标题"); apply1.SetAttribute("styles","CaptionFont"); XmlElement apply2 = Chart.CreateElement("style"); apply2.SetAttribute("toObject","SubCaption"); apply2.SetAttribute("styles","SubCaptionFont"); application.AppendChild(apply1); application.AppendChild(apply2); Chart.DocumentElement.AppendChild(Style); Response.Write(Chart.OuterXml); } } }
"); Chart.DocumentElement.SetAttribute("pieSliceDepth", "30"); Chart.DocumentElement.SetAttribute("startingAngle", "125"); Chart.DocumentElement.SetAttribute("showValues", "0"); XmlDocument LossTimeXml = new XmlDocument(); XmlDocument TotalTimeXml = new XmlDocument(); //string fmdt = Request.QueryString["FromDate"].ToString(); //string tdt = Request.QueryString["ToDate"].ToString(); //string did = Request.QueryString["did"].ToString(); double lt, tt, result; string st = DAL.GenericSP_Str(2, "Sp_GetTruckTrackingPieChart", "<Root FromDate=\"" + Request.QueryString["FromDate"] + "\" Todate=\"" + Request.QueryString["ToDate"] + "\" />"); LossTimeXml.LoadXml(st); string slt = Convert.ToString(LossTimeXml.DocumentElement.GetAttribute("value")); string stt = Convert.ToString(LossTimeXml.DocumentElement.GetAttribute("TotalVehicles")); lt = Convert.ToDouble(slt); tt = Convert.ToDouble(stt); result = (lt / tt) * 100; XmlElement ActiveElement = Chart.CreateElement("set"); ActiveElement.SetAttribute("label", "Active" + "(" + lt + ")" + "[" + Math.Round(result, 2) + "% ]"); ActiveElement.SetAttribute("value", Math.Round(result, 2).ToString()); ActiveElement.SetAttribute("link", "P-detailsPopUp,width=800,height=550,toolbar=no,scrollbars=no,resizable=no-TruckDailyChart.aspx?FromDate=" + Request.QueryString["FromDate"] + "&ToDate=" + Request.QueryString["ToDate"] + "&Status=" + "1" + "&label=Active"); Chart.DocumentElement.AppendChild(ActiveElement); TotalTimeXml.LoadXml(DAL.GenericSP_Str(2, "Sp_GetTruckTrackingPieChartInActive", "<Root FromDate=\"" + Request.QueryString["FromDate"] + "\" Todate=\"" + Request.QueryString["ToDate"] + "\" />")); lt = Convert.ToDouble(TotalTimeXml.DocumentElement.GetAttribute("value")); tt = Convert.ToDouble(TotalTimeXml.DocumentElement.GetAttribute("TotalVehicles")); result = (lt / tt) * 100; XmlElement InActiveElement = Chart.CreateElement("set"); InActiveElement.SetAttribute("label", "InActive" + "(" + lt + ")" + "[" + Math.Round(result, 2) + "% ]"); InActiveElement.SetAttribute("value", Math.Round(result, 2).ToString()); InActiveElement.SetAttribute("link", "P-detailsPopUp,width=800,height=550,toolbar=no,scrollbars=no,resizable=no-TruckDailyChart.aspx?FromDate=" + Request.QueryString["FromDate"] + "&ToDate=" + Request.QueryString["ToDate"] + "&Status=" + "2" + "&label=InActive"); Chart.DocumentElement.AppendChild(InActiveElement); XmlElement Style = Chart.CreateElement("styles"); XmlElement definition = Chart.CreateElement("definition"); Style.AppendChild(definition); XmlElement style1 = Chart.CreateElement("style"); style1.SetAttribute("type", "font"); style1.SetAttribute("name", "CaptionFont"); style1.SetAttribute("size", "15"); style1.SetAttribute("color", "666666"); XmlElement style2 = Chart.CreateElement("style"); style2.SetAttribute("type", "font"); style2.SetAttribute("name", "SubCaptionFont"); style2.SetAttribute("bold", "1"); definition.AppendChild(style1); definition.AppendChild(style2); XmlElement application = Chart.CreateElement("application"); Style.AppendChild(application); XmlElement apply1 = Chart.CreateElement("style"); apply1.SetAttribute("toObject", "caption"); apply1.SetAttribute("styles", "CaptionFont"); XmlElement apply2 = Chart.CreateElement("style"); apply2.SetAttribute("toObject", "SubCaption"); apply2.SetAttribute("styles", "SubCaptionFont"); application.AppendChild(apply1); application.AppendChild(apply2); Chart.DocumentElement.AppendChild(Style); Response.Write(Chart.OuterXml); } } }




我在此代码中遇到错误:




i''m getting error in this code:

string Para = "EquipmentID=" + ((XmlElement)CategoryLst[j]).GetAttribute("UnitID");
                                Para = Para + "&Section=" + section;
                                Para = Para + "&StartDate=" + FromDate;
                                Para = Para + "&EndDate=" + ToDate;
                                Para = Para + "&Status=" + (i + 1).ToString();
                                Para = Para + "&label=" + ((XmlElement)CategoryLst[j]).GetAttribute("label");
SetElement.SetAttribute("link", "EquipmentInActive.aspx?" + Para);//Error on this line



请帮我.

谢谢



plzzz help me.

thanks


link =''EquipmentActive.aspx?EquipmentID = 21&Section = 2&StartDate = 5/25/2014&EndDate = 6/3/2014&Status = 1&label = 40-303''/>
&是xml中的非法字符.
使用和代替.
link=''EquipmentActive.aspx?EquipmentID=21&Section=2&StartDate=5/25/2014&EndDate=6/3/2014&Status=1&label=40-303'' />
& is an illegal character in the xml.
Use &amp; instead.