What are the potential reasons for the code snippet not producing any output when attempting to extract specific content from a webpage in PHP?

The code snippet may not be producing any output due to errors in the way the content is being extracted from the webpage. To solve this issue, ensure that the webpage is successfully loaded and the content is correctly selected using the appropriate selectors. Additionally, check for any errors in the PHP code that may be preventing the output from being displayed.

<?php
// Create a new DOMDocument object
$doc = new DOMDocument();

// Load the webpage content
$doc->loadHTMLFile('https://www.example.com');

// Use DOMXPath to query and extract specific content
$xpath = new DOMXPath($doc);
$elements = $xpath->query('//div[@class="content"]');

// Check if elements were found
if ($elements->length > 0) {
    // Output the extracted content
    foreach ($elements as $element) {
        echo $element->textContent;
    }
} else {
    echo "No content found.";
}
?>