Sign in to follow this  
bert.dillien

Invalid XML data

Recommended Posts

Hi all,

 

 

 

I'm a bit stuck trying to create a simple 3D Pie chart.

 

 

 

I've tried a number of different ways to create my data xml, but it is returning an invalid error.

 

 

 

Sample code:

 

 

 

<script type="text/javascript" src="FusionCharts.js"></script>

 

<div id=xmlData">

 

<chart caption="Hello Chart" palette="1">

 

<set label="A label" value="1" />

 

<set label="B label" value="2" />

 

<set label="C label" value="3" />

 

<set label="D label" value="4" />

 

</chart>

 

</div>

 

<div id="graph">

 

<script type="text/javascript">

 

oChart = new FusionCharts('Pie3D.swf','graph','300','200','1','1');

 

oChart.setDataXML(document.getElementById('xmlData').innerHTML);

 

oChart.render('graph');

 

</script>

 

</div>

 

 

 

The XML is created via the XMLGenerator tool, and kept very simple to try it out first. The actual data is of the same structure, exception on the values which would contain decimal places.

 

 

 

Is there something I am missing?

 

 

 

Thanks!

Edited by Guest

Share this post


Link to post
Share on other sites
Guest Basundhara Ghosal

Hi,

Welcome to FusionCharts Forum. :D

Could you please try using a double quote in the line refered below of your XML code:-

Ref.- <div id=xmlData">

Hope this helps. :)

 

Share this post


Link to post
Share on other sites

Hi,

 

 

 

Thanks for the reply, but I found out it was due to difference in swf versions. I was working with a 2.3 and reading the 3.3 documentation. Once I found the correct charts (puchased v3.0 some years ago...yeah, badly classified) it worked like a charm!

 

 

 

Also, in the example above, I needed to change all xmlData contents to replace all double quotes by single ones in javascript.

 

So this line : oChart.setDataXML(document.getElementById('xmlData').innerHTML);

 

becomes : oChart.setDataXML(document.getElementById('xmlData').innerHTML.replace(/"/g,''');

 

and it works fine.

 

 

 

It seems that the setDataXML methode cannot parse a double quote. Also in IE8, the XML put in the xmlData div gets parsed somehow by IE, making all single quote's into double ones... very strange behaviour.

 

 

 

Cheers.

Edited by Guest

Share this post


Link to post
Share on other sites
Guest Basundhara Ghosal

Hi,

 

 

 

Thanks for your appreciation.

 

 

 

As setDataXML method is tagged with the JavaScript function, in setDataXML method all double quotes are required to be replaced by single quotes because the JavaScript function uses double quotes for the attributes.

 

 

 

Happy FusionCharting. :D

Edited by Guest

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