Sign in to follow this  
NoBullMan

Invalid Xml Data

Recommended Posts

Hi,

I am getting Invalid XML Data error and not sure how to resolve it. Some charts display OK and some don't. When I compare the content of XML Data between the ones that work and the ones that don't, the only difference between them is the existence of special characters, like &.

Before appending Label/Value pair, I replace all occurences of special characters with their html equivalant ('&' with '&', single quote with '''. etc.) but still get the error. Not sure what else to do or waht else could be wrong.

(I am doing this in ASP.Net, C#):

 

foreach (DataRow dr in table.Rows)

 

{

 

string sLabel = dr["Name"].ToString().Replace("'", "'").Replace("&", "&").Replace("\"", "&quote;").Replace("\\", "\\\\");

 

xmlData.AppendFormat("<set label='{0}' value='{1}' /> ", sLabel, Convert.ToInt16(dr["Count"]));

 

}

 

xmlData.Append("</chart>");

 

return FusionCharts.RenderChartHTML("Charts/FusionCharts/Pie3D.swf", "", xmlData.ToString(), "Dist", "500", "250", true);

 

]

 

I traced the code and turned on debugging for chart and this is the final XML data (it is 3-D Pie Chart):

 

<chart caption='Machine Distribution' subcaption='(12/14/2010)' lineThickness='1' showValues='1' labelDisplay='Stagger' formatNumberScale='0' anchorRadius='2' divLineAlpha='20' divLineColor='CC3300' divLineIsDashed='1' showAlternateHGridColor='1' alternateHGridColor='000099' shadowAlpha='40' labelStep='1' numvdivlines='5' chartRightMargin='35' bgColor='FFFFFF,000099' bgAngle='270' bgAlpha='10,10' alternateHGridAlpha='5' yAxisName='Rate' yAxisMaxValue='50' lineColor='FF5904'>

 

<set label='ANCHORAGE AMF ' value='11' />

<set label='CEDAR RAPIDS (IA) PDF' value='11' />

<set label='DENVER (CO) PDC ' value='89' />

<set label='DES MOINES (IA) PDC' value='30' />

<set label='EVERETT PDF' value='24' />

<set label='KANSAS CITY (MO) PDC' value='60' />

<set label='MINNEAPOLIS (MN) P&DC' value='61' />

<set label='OMAHA (NE) PDC' value='24' />

<set label='PHOENIX (AZ) PDC' value='7' />

<set label='PORTLAND (OR) PDC' value='33' />

<set label='QUAD CITIES (IL) PDF' value='12' />

<set label='SAINT PAUL (MN) PDC' value='46' />

<set label='SALT LAKE CITY (UT) PDC' value='39' />

<set label='SEATTLE (WA) PDC' value='39' />

 

</chart>

 

This is the error I see in debug window:

 

ERROR: Invalid XML encountered. An attribute value is not properly terminated. Click the above "dataURL Invoked" link to see the XML in browser Or check the XML data provided.

 

Also, it says 'click the above dataURL Invooked link', but I don;t see any such link to click.

 

Thanks.

Edited by NoBullMan

Share this post


Link to post
Share on other sites
Guest Angie

Hi,

 

Welcome to FusionCharts Forum!smile.gif

 

When you are using the HTML embedding method with data provided as embedded string, it is essential to encode & character to %26.

I'm glad to know your issue has been resolved.

Happy FusionCharting!biggrin.gif

 

Edited by Angie

Share this post


Link to post
Share on other sites
Guest Angie

Hi,

 

Welcome to FusionCharts Forum!smile.gif

 

When you are using the HTML embedding method with data provided as embedded string, it is essential to encode & character to %26.

 

 

I'm glad to know your issue has been resolved.

 

 

Happy FusionCharting!biggrin.gif

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this