Jump to content

seyedrezabazyar

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by seyedrezabazyar

  1. I have two codes at the bottom. The first code is a scraper file that captures and displays the contents of a web page from the "div" tag. index code: function curlGet($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_URL, $url); $results = curl_exec($ch); curl_close($ch); return $results; } function returnXPathObj($item) { $xmlPageDom = new DomDocument(); @$xmlPageDom->loadHTML($item); $xmlPageXPath = new DOMXPath($xmlPageDom); return $xmlPageXPath; } echo returnXPathObj(curlGet('http://localhost/test/page'))->query('//div')->item(0)->nodeValue; // This URL refers to a page that contains the following code The second code is the contents of that web page webpage code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div class="content"> <h1>phpfreaks</h1> <p>www.phpfreaks.com</p> </div> <span class="content2"> <h1>phpfreaks</h1> <p>www.phpfreaks.com</p> </spans> </body> </html> Now when I run the code, it only shows the text and hides the HTML tags. How can I display the contents of the Dave tag along with all the HTML tags? for example: Now displays as follows: phpfreaks www.phpfreaks.com I want to show the following: <h1>phpfreaks</h1> <p>www.phpfreaks.com</p>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.