无效的xml ...使用C#生成融合图时出现问题 [英] Invalid xml ... problem generating fusion chart using c#

查看:104
本文介绍了无效的xml ...使用C#生成融合图时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用c#在asp.net页面中处理融合图.

n

我也阅读了它的文档.

我经过数小时的努力,但是得到了无效的xml来生成融合图.

我正在获取此xml,请检查它,如果错误的地方让我知道.

图表中的链接引起了问题,
如果我删除链接,则此代码工作正常....


Hi guys,

I''m working on fusion charts in my asp.net page using c#.

n

i have gone through with its documentation as well.

i''m tried hard from the hours, but getting invalid xml to generate fusion charts.

i''m getting this xml, plz check it, if its some where wrong plzzz let me know.

The link in the chart is making the problem,
if i remove the link then this code is working fine....


<chart caption=''NATIONAL PETROLEUM SERVICES'' palette=''1'' animation=''1'' formatNumberScale=''0'' startingAngle=''125'' baseFontSize=''15'' baseFontBold=''1'' labelDisplay=''rotate''>
<categories>
<category label=''40-301'' UnitID=''20'' />
<category label=''40-303'' UnitID=''21'' />
<category label=''40-305'' UnitID=''13'' />
<set value='''' color=''#00FF00'' />
<set value=''4'' color=''#00FF00'' link=''EquipmentActive.aspx?EquipmentID=21&Section=2&StartDate=5/25/2014&EndDate=6/3/2014&Status=1&label=40-303'' />
/></categories><dataset seriesName=''Active''><set value='''' color=''#00FF00'' /><set value=''4'' color=''#00FF00'' link=''EquipmentActive.aspx?EquipmentID=21&Section=2&StartDate=5/25/2014&EndDate=6/3/2014&Status=1&label=40-303'' />
<set value='''' color=''#00FF00'' />
<set value='''' color=''#00FF00'' />
<set value='''' color=''#00FF00'' />
<set value='''' color=''#00FF00'' />
<set value='''' color=''#00FF00'' />
</dataset>
</chart>



C#代码:



c# code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using DataAccessLayer;

namespace NPSDashboard
{
    public partial class TruckPieChartData : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Generate_chart();
        }

        protected void Generate_chart()
        {
            XmlDocument XDoc = new XmlDocument();

            XmlDocument Chart = new XmlDocument();
            Chart.LoadXml("<chart />");
            Chart.DocumentElement.SetAttribute("caption", "NATIONAL PETROLEUM SERVICES");
            Chart.DocumentElement.SetAttribute("palette", "2");
            Chart.DocumentElement.SetAttribute("animation", "1");
            Chart.DocumentElement.SetAttribute("formatNumberScale", "0");
            //Chart.DocumentElement.SetAttribute("numberPrefix", "$");
            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

推荐答案

); 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.


这篇关于无效的xml ...使用C#生成融合图时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆