Title: Getting an XML file in a .asp URL
Tags: php;asp.net;xml
Question: I need to grab XML data from an .asp URL and cannot figure out where it goes wrong. Tried:
<?php
$url = "http://bookings.emperordivers.com/webScheduleSpecificXML_all.asp";
$feed = file_get_contents($url);
$xml = simplexml_load_string($feed);
// Display the first post title
echo $xml-&gt;Schedules-&gt;Schedule[0]-&gt;Boat;
I hoped this would work, but suspected that the .asp URL is blocking somehow so alternatively tried:
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
$returned_content = get_data('http://bookings.emperordivers.com/webScheduleSpecificXML_all.asp');
$xml = simplexml_load_string($returned_content);
// Display the first post title
echo $xml-&gt;Schedules-&gt;Schedule[0]-&gt;Boat;
In both case a beautiful white screen. Is there a simple trick to get this working?
Comment: Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.


Here is another answer: Your not accessing it correctly:
echo $xml-&gt;Schedule[0]-&gt;Boat;
The format is:
SimpleXMLElement Object
[Schedule] =&gt; Array
(
[0] =&gt; SimpleXMLElement Object
(
[Start] =&gt; 2017-09-24
[Duration] =&gt; 7
[Boat] =&gt; MV Emperor Orion
[Itinerary] =&gt; Best of Maldives
[Dep-Arr] =&gt; Male
[Spaces] =&gt; 4
[Rates] =&gt; SimpleXMLElement Object
(
[Rate] =&gt; Array
(
[0] =&gt; 1149
[1] =&gt; 1,057.08
[2] =&gt; 1,367.31
)
)
)
Comment for this answer: Thanks Lawrence,  though . . .just skipping the  ['code'](->Schedules) from the code still does give me a white screen. I am just beginning to wrap my head around all this, so any advise (as close as possible to common English) highly appreciated.
Comment for this answer: Still neither or the 2 are working. Is the get_file_contents or the curl code the better solution? Both still giving me a white screen.
Comment for this answer: Tried with following error:
Warning: file_get_contents(http://bookings.emperordivers.com/webScheduleSpecificXML_all.asp): failed to open stream: HTTP request failed! in /Users/John/Sites/test.php on line 7
Notice: Trying to get property of non-object in /Users/John/Sites/test.php on line 13
Notice: Trying to get property of non-object in /Users/John/Sites/test.php on line 13
Comment for this answer: Currently on localhost, but tried with different xml feed, works. Tried now also with useragent as you made and same error. Will try on host online now.
Comment for this answer: I just used the fgc one, https://codepad.remoteinterview.io/IEVQTYHJRS - Try enabling error reporting perhaps somethings disabled.
Comment for this answer: It looks as if you may be blocked for some reason, then it returns nothing and the rest fails, you could try curl with setting useragent, whos your host?
Comment for this answer: It could be your firewall settings or such.
Comment for this answer: np, glad to help

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:09/18/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<php><asp.net><xml>', 'Title': 'Getting an XML file in a .asp URL', 'ViewCount': 41, 'id': 46273977, 'user_AboutMe': '', 'user_AccountId': 11779397.0, 'user_DisplayName': 'John', 'user_Reputation': 17.0, 'user_Views': 7.0, 'user_id': 8619603.0}}