A workaround for invalid XML data error prompts when you use Fusioncharts to generate a chart
Source: Internet
Author: User
Fusioncharts is really powerful enough. The collection of functions is estimated to be more powerful. In the first use, the manual, step-by-step operation is to generate the chart tool is not successful. Always report "Invalid XML data" error.
After the investigation, found that there may be several issues.
1, XML file format problem. Especially pairing symbols. Make sure that the access is OK.
2, the XML file BOM problem. If you have Chinese in your XML file, be sure to increase the BOM. Added in Dreamweaver, is to open the XML file-> ' modify ' Menu-> ' page Properties '-> ' title/encoding '-> ' including Unicode signature (BOM) ' Before the check box is selected. And then click OK. This error can be resolved in the Chinese XML report.
By the way, let me tell you a little trick. Is that when we write a program that contains an XML file, it is
Mychart.setdataurl ("/data.xml");
But our data is basically dynamically generated. We can actually include a PHP program. The XML is then exported through a PHP program. This will be a good way to achieve the goal.
Such as:
Mychart.setdataurl ("/charts_ajax_show.php");
Then the charts_ajax_show.php program is as follows:
PHP Code copies content to clipboard <?php header ("Content-type:text/xml;charset=utf-8"); echo "<?xml version= ' 1.0 ' encoding= ' utf-8 '?>"; echo "<graph caption= ' monthly Sales Column chart ' xaxisname= ' month ' yaxisname= ' unit ' shownames= ' 1 ' decimalprecision= ' 0 ' formatnumberscale= ' 0 ' > <set name= ' January ' value= ' 462 ' color= ' afd8f8 ', ' hovertext= ' January sales '/> <set ' February ' name= ' 857 ' color= ' f6bd0f ' showname= ' 0 '/> <set name= ' March ' value= ' 671 ' color= ' 8bba00 ' '/> <set ' name= ' April ' value= ' 494 ' C olor= ' Ff8e46 '/> <set name= ' May ' value= ' 761 ' color= ' 008e8e ',/> <set ' name= ' June ' value= ' 960 ' color= ' D64646 ' <set name= ' July ' value= ' 629 ' color= ' 8e468e '/> <set ' name= ' August ' value= ' 622 ' color= ' 588526 ',/> <set ' name= ' September ' V Alue= ' 376 ' color= ' b3aa00 '/> <set ' name= ' October ' value= ' 494 ' ' color= ' 008ed6 '/> <set ' the name= ' November ' value= ' 761 ' ' color= ' 9d080d '/> <set name= ' December ' value= ' 960 ' color=, ' a186be '/> </graph> ';
Notice that I have a code in my PHP program:
PHP Code copies content to the Clipboard header ("Content-type:text/xml;charset=utf-8");
Text/xml means to tell the browser to output XML. If you don't add this. It's definitely not going to work.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.