javascript - Make copy of XML page using PHP -
i'm trying use javascript access data http://www.bart.gov/dev/eta/bart_eta.xml , however, found out cannot unless have copy of page on server. how can make proxy page on server exact copy of http://www.bart.gov/dev/eta/bart_eta.xml ? have tried simplexml_load_file , file_get_contents, both functions not give me xml format, give me object(simplexmlelement)#1 (2) { ["channel"]=> object(simplexmlelement)#2 (6) { ["title"]=> string(23) "bart real time eta feed" ["link"]=> string(50) "http://www.bart.gov/schedules/developers/etas.aspx" ["description"]=> string(127) "real time estimated arrivals bay area rapid transit. use subject terms @ http://www.bart.gov/dev/schedules/license.htm" ["copyright"]=> string(86) "copyright (c) 2012 san francisco bay area rapid transit district. rights reserved." ["date"]=> string(10) "07/01/2012" ["time"]=> string(15) "02:52:39 pm pdt" } ["station"]=> array(44) { [0]=> object(simplexmlelement)#3 (5) { ["name"]=> string(12) ...
you need send content type first.
put following file on server bart_eta_proxy.php
example, , try access it.
header("content-type: text/xml; charset=utf-8"); echo file_get_contents('http://www.bart.gov/dev/eta/bart_eta.xml');
and here go, it's working:
Comments
Post a Comment