Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3226274
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:26:12+00:00 2026-05-17T16:26:12+00:00

The code pasted below, works on my PC, but not on my hosting (which

  • 0

The code pasted below, works on my PC, but not on my hosting (which have PHP 5.2.13 installed).

$source = file_get_contents('http://example.com/example', 0);
$dom = new DOMDocument;
@$dom->loadHTML($source);
$dom->preserveWhiteSpace = false;

$xpath = new DOMXPath($dom);
$tags = $xpath->query('//div[@class="item"]');

$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n<root>\r\n";

foreach($tags as $tag)
    $xml .= "\t<tag>" . trim($tag->nodeValue) . "</tag>\r\n";

$xml .= '</root>';

$xml_file = 'tags.xml';
$fopen_handle = fopen($xml_file, 'w+');
fwrite($fopen_handle, $xml);
fclose($fopen_handle);

On my hosting, the foreach loop doesn’t executes i.e. I get only this in the XML:

<?xml version="1.0" encoding="UTF-8"?>
<root>
</root>

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:26:12+00:00Added an answer on May 17, 2026 at 4:26 pm

    Your hosting doesn’t support file_get_contents (allow_url_fopen is the setting iirc)

    Try this:

    $ch = curl_init();
    $timeout = 0;
    curl_setopt ($ch, CURLOPT_URL, 'http://example.com');
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $file_contents = curl_exec($ch);
    curl_close($ch); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code I have pasted below is meant to display images on the middle
Code below does not run correctly and throws InvalidOperationExcepiton . public void Foo() {
I have a code below that try to identify the position of start and
I have been having an ongoing fight with this email setup. The code below
This code below works perfectly for all browsers except IE 7 or 8. <img
If i try to paste source code in word 2007 the spacing between the
In this abbreviated code, the inline event works - the event is passed to
Code: <html xmlns=http://www.w3.org/1999/xhtml> <head> <title>Unusual Array Lengths!</title> <script type=text/javascript> var arrayList = new Array();
Code I have: cell_val = CStr(Nz(fld.value, )) Dim iter As Long For iter =
I am using the class pasted below to listen for the keypress event ctrl

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.