I want to use PHP to load a XML from a URL like "HTTP://127.0.0.1/19/1", how can I do it? I tried several ways but they all failed.. so just ask for help here..thanks
3
-
1What did you try, and why does it fail(error-message)?Dr.Molle– Dr.Molle2012-07-12 18:02:52 +00:00Commented Jul 12, 2012 at 18:02
-
I tried things on this website, php.net/manual/en/function.simplexml-load-file.phpuser1519773– user15197732012-07-12 18:09:44 +00:00Commented Jul 12, 2012 at 18:09
-
What do you get if you load the URL in a browser? If you don't see the XML (or, as @qxxx suspects, you see a login prompt) then the problem is with the URL you're using, not PHP/simplexmldimo414– dimo4142012-07-12 18:16:19 +00:00Commented Jul 12, 2012 at 18:16
Add a comment
|
1 Answer
<?php
$x=simplexml_load_file("HTTP://127.0.0.1/19/1");
?>
2 Comments
user1519773
I get error like this:failed to open stream: HTTP request failed! HTTP/1.1 401 OK
MilMike
401 means that you need to enter a user/password first... or the request is blocked for some other reason - try this: $x=simplexml_load_file("HTTP://user:[email protected]/19/1"); (but I didn't try this)