Jump to content

Errors with dom handling


Ninjakreborn

Recommended Posts

This doesn't work. Based off what I have seen online, it is suppose to.

 

Basically, this is what I tried, and the quote is what was returned. I have no idea how to get this to work. It should have been pretty standard

based off of the PHP documentation. The Xpath idea I got from someone else. Either way if I try to use find element by id or tag name it still

returns an empty array, no matter what.

 

Any advice on what I am doing wrong is appreciated. It doesn't matter what URL I try, none of them seem to work.

<?php		
	$school_data = file_get_contents('http://www.infotechnologist.biz');
	$doc = new DOMDocument();
	$doc->validateOnParse = true;
	$doc->loadHTML($school_data);
	$xpath = new DOMXPath($doc);
	$tags = $xpath->query('div');
	echo '<pre>';
	print_r($tags);
	echo '</pre>';
?>

DOMNodeList Object

(

)

Link to comment
https://forums.phpfreaks.com/topic/221802-errors-with-dom-handling/
Share on other sites

I tried using that extensively as well as tried many things with HTML Simple Dom. The stuff I am trying to do doesn't seem to be working here.

Is it easier/better to parse HTML using Regex and getting what you need as you need it from the pages instead?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.