Sign in to follow this  
boywithk9

xml file on different server

Recommended Posts

Is it possible to host the xml file on a different server from the site itself? I'm switching to a provider that provides a CMS to manage my site, and it would be more time-consuming for me to have to individually upload all the xml files every time they change (there's no FTP allowed, so I have to use the CMS's file manager to upload files one by one). I could FTP the xml files to a different domain I own, but the charts don't seem to work when the xml files are hosted on a different domain.

Share this post


Link to post
Share on other sites

I see in another thread that the following code would solve my problem:

 

 

 

<?php

 

$xmlDoc = new DOMDocument();

 

$xmlDoc->load("http://www.fusioncharts.com/Gallery/Data/Col3D1.xml");

 

header('Content-type: text/xml');

 

echo $xmlDoc->saveXML();

 

?>

 

 

 

However, I'm not a programmer, and I have no idea where to put this or what it means. Does it go in the head of the php file? If I have multiple charts on a page, do I duplicate the code for each chart? What do I do with the myChart.setDataURL, which is what currently points to the file?

 

 

 

Thanks

Share this post


Link to post
Share on other sites

Hi,

 

 

 

To make it less technical you can have a separate file (relay file) for each chart/each XML.

 

 

 

You need to pass the URL of this relay file to the setDataURL function.

 

 

 

If you can try a bit, you can develop a single file which would relay all the XML files you need from the other domain.

 

 

 

To this script, say if named relayer.php, you can pass the URL of the required XML and this file in turn can pass the chart the XML it needs.

 

 

 

 

 

So, the code can be:

 

 

 

In JavaScript (for different charts)

 

 

 

myChart.setDataURL(escape("realyer.php?XML=http://www.mydomain.com/xml/myXML1.xml"));

 

 

 

myChart.setDataURL(escape("realyer.php?XML=http://www.mydomain.com/xml/AnotherXML.xml"));

 

 

 

myChart.setDataURL(escape("realyer.php?XML=http://www.mydomain.com/otherSource/newXML.xml"));

 

 

 

myChart.setDataURL(escape("realyer.php?XML=http://www.anotherdomain.com/myXML.xml"));

 

 

 

 

 

and

 

the realyer.php would be:

 

 

 

<?php

 

$xmlDoc = new DOMDocument();

 

$xmlDoc->load($_GET["XML"]);

 

header('Content-type: text/xml');

 

echo $xmlDoc->saveXML();

 

?>

Share this post


Link to post
Share on other sites

Well, I guess I spoke too soon -- it's not working.

 

 

 

I had the relayer.php file placed on the server, and I've tested it by going to:

 

 

 

http://domain.com/inc/php/relayer.php?XML=http://www.remotedomain.com/cjdeheercom/stats/data_sfh_median.xml

 

 

 

That correctly returned the remote .xml file.

 

 

 

And the code I've placed on the page calling the relayer file is:

 

 

 

myChart.setDataURL(escape("/inc/php/relayer.php?XML=http://www.remotedomain.com/cjdeheercom/stats/data_sfh_median.xml"));

 

 

 

But I get an "error in loading data" message...

Share this post


Link to post
Share on other sites

Here's the output from debug mode:

 

 

 

Info: Chart loaded and initialized.

 

Initial Width: 715

 

Initial Height: 375

 

Scale Mode: noScale

 

Debug Mode: Yes

 

Application Message Language: EN

 

Version: 3.1.1

 

Chart Type: Multi Series 2D Combination Chart

 

Chart Objects:

 

BACKGROUND

 

CANVAS

 

CAPTION

 

SUBCAPTION

 

YAXISNAME

 

XAXISNAME

 

DIVLINES

 

YAXISVALUES

 

HGRID

 

DATALABELS

 

DATAVALUES

 

TRENDLINES

 

TRENDVALUES

 

DATAPLOTCOLUMN

 

DATAPLOTLINE

 

DATAPLOTAREA

 

ANCHORS

 

TOOLTIP

 

VLINES

 

LEGEND

 

VLINELABELS

 

 

 

INFO: Chart registered with external script. DOM Id of chart is myChartId

 

INFO: XML Data provided using dataURL method.

 

dataURL provided: /inc/php/relayer.php?XML=http://www.deheer.com/cjdeheercom/stats/data_sfh_median.xml

 

dataURL invoked: /inc/php/relayer.php?XML=http://www.deheer.com/cjdeheercom/stats/data_sfh_median.xml&FCTime=144

 

ERROR: An error occurred while loading data. Please check your dataURL, by clicking on the "dataURL invoked" link above, to see if it's returing valid XML data. Common causes for error are:

 

No URL Encoding provided for querystrings in dataURL. If your dataURL contains querystrings as parameters, you'll need to URL Encode the same. e.g., Data.asp?id=101&subId=242 should be Data%2Easp%3Fid%3D101%26subId%3D242

 

Different sub-domain of chart .swf and dataURL. Both need to be same owing to sandbox security.

 

Network error

Share this post


Link to post
Share on other sites

hi.

 

please update your code a little bit.....

 

 

 

write

 

myChart.setDataURL("realyer.php?XML=www.anotherdomain.com/myXML.xml");

 

**omit the http:// in the chart dataURL

 

 

 

update relayar.php page alse as follows

 

<?php

 

$xmlDoc = new DOMDocument();

 

$xmlDoc->load('http://'.$_GET["XML"]);

 

header('Content-type: text/xml');

 

echo $xmlDoc->saveXML();

 

?>

 

 

 

 

 

fusionchatrs block urls containing ':' that's why it's blocking the the url supplyed in the dataURL

Share this post


Link to post
Share on other sites

Thanks! Since I have to have a programmer make changes to the relayer file (they don't provide access to the php files for security reasons), I just wanted to confirm that the period following the code you added is not a mistake before I ask them to make the change. Can you confirm that for me?

 

 

 

Thanks again.

Share this post


Link to post
Share on other sites
Guest Madhumita

Hello,

We confirm that the "period" in the code we added is correct. It is being used for concatenating the strings.

 

Please keep us updated. :)

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