Jump to content

Extracting Div Contents


N-Bomb(Nerd)

Recommended Posts

Alright, so after some investigating as to why this wasn't working.. it appears in some of the divs there's actually more divs inside.. therefore it could read a div inside of the div I'm trying to get and close early.

 

Would using DOM actually solve my problem here? The thing is, I've never used DOM in my life and I have no idea how I would set that up.

But you said earlier...

Also, forgot to mention that I can't use DOM in this case.. has to be regex.

 

anywhoo....yes, the problem is that regex does not handle nested tagging very well.  More accurately, it handles it very poorly.  The core of DOM is in fact regex, but the broader scope of DOM is that it goes through and creates a well, model (hence the name) of the page, as a whole.  So it properly matches opening/closing tags up by looking at the document as a whole. 

 

So you can use regex, but in order to make it any kind of accurate, you're going to have to look at the content as a whole and walk through everything matching them up...which is reinventing the wheel. 

 

There is already another active thread about DOM on this very page that looks suspiciously familiar to this thread (trying to get contents of a div...asking for a regex solution, being told about DOM...hmm...not insinuating anything..just..awfully coincidental...).  Anyways..it's on the front page of the forum, so look into how to do the whole DOM thing there. 

 

edit: in fact, I'll even give you a link to it, save yourself the trouble of trying to find it.  http://www.phpfreaks.com/forums/index.php/topic,256532.0.html

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.