[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1293
  • Last Modified:

reading xml content from a url

i have a url

and  it has xml content

i want to read this xml content usign php

can any one please help me out

Thank you

2 Solutions
You can just use:

$xml = file_get_contents('http://domain.com/xmlfile.xml');

srikanthmadishettiAuthor Commented:
$xml = file_get_contents('http://preisvergleich.guenstig.de/xservice/getCategoryList.do?version=2.3');

iam tryign to read like this it throws errors

thatz the url from where i need to read the xml content and i want the seperated content
What kind of errors. The url seems to work for me.

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

If you look in the PHP manual it notes -

Tip: You can use a URL as a filename with this function if the fopen wrappers have been enabled.

The feature to enable/disable this is this one -

allow_url_fopen boolean
  This option enables the URL-aware fopen wrappers that enable accessing URL
   object like files. Default wrappers are provided for the access of remote files
  using the ftp or http protocol, some extensions like zlib may register additional

However, fopen wrappers can be a security risk and can be disabled by security conscious admins, especially on shared hostng.  Check it is not enabled.
srikanthmadishettiAuthor Commented:
Warning: file_get_contents(): php_network_getaddresses: gethostbyname failed in D:\guenstig\guenstig1\gunxml.php on line 4

Warning: file_get_contents(http://preisvergleich.guenstig.de/xservice/getCategoryList.do?version=2.3): failed to open stream: No such file or directory in D:\guenstig\guenstig1\gunxml.php on line 4

this is the error it gives to me
srikanthmadishettiAuthor Commented:
i kept the allow_url_fopen- on in php.ini file but still i get the same error.

srikanthmadishettiAuthor Commented:
but i want to know after reading the file using file_get_contents how can i get the seperated content like we have starting tag ending tags <itmes></itmes> so i want all the contents of this xml contents
Hello ,

Use CURL instaed of fopen to read the URL.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now