Jump to content

Get div with longest length from remote webpage


yanjchan

Recommended Posts

Hi!

Does anyone here know how to find out which div has the most text in it on a remote webpage?

For example, if the remote webpage looked like this:

 

<html>
<head>
<title>Hi</title>
</head>
<body>
<div id="big">sjdf0afh0u9 4uf0a udf8saudfo9aufosalfd</div>
<div id="small">iaosjfioajdf</div>
</body>
</html>

 

the PHP script would find out that the "big" div was the biggest and return its id and contents.

 

So far, I discovered a method of doing this ... provided the site was pure XML. Unfortunately, not all webpages parsed by this script can be trusted to be as such.

 

Thanks in advance!

Hi!

Thanks for replying.

The problem is that the DOM throws errors on things such as ul and nbsp.

This is unacceptable, as for obvious reasons I cannot ask everyone who submits a site to write perfectly good XML without those elements.

 

THanks.

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.