Jump to content

Using Document Object Model to get entire img tag


beingalex

Recommended Posts

Hi Guys,

 

I'm trying to use the DOMDocument to get an entire img tag (from the "<img" to the "/>"). Is this possible ?

I have to get the first img tag that is found in a string of html. Here is what I have so far:

 

$dom = new DOMDocument();
$dom->preseveWhiteSpace = FALSE;
@$dom->loadHTML($post->post_content);
                            
$images = $dom->getElementsByTagName("img");

 

"post_content" definitely returns a string of html with an img tag in it, however all my attemps to get that tag have failed.

 

Any help is much appreciated, thank you in advance

 

- Alex

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.