Jump to content

extract


1zeus1

Recommended Posts

or need to extract all h1 tags and insert into database

You can modify this code to make it work?

//////////////////////////////////////////////////////////////////

function getTextBetweenTags($tag, $get, $strict=0)

{

/*** a new dom object ***/

$dom = new domDocument;

 

/*** load the html into the object ***/

if($strict==1)

{

$dom->loadXML($get);

}

else

{

$dom->loadHTML($get);

}

 

/*** discard white space ***/

$dom->preserveWhiteSpace = false;

 

/*** the tag by its tag name ***/

$content = $dom->getElementsByTagname($tag);

 

/*** the array to return ***/

$out = array();

foreach ($content as $item)

{

/*** add node value to the out array ***/

$out[] = $item->nodeValue;

}

/*** return the results ***/

return $out;

}

$content = getTextBetweenTags('h1', $get);

 

foreach( $content as $item )

{

$h1 = $item.'<br />';

}

 

$query="UPDATE sitis SET

hh = '$h1' WHERE id = '$a'";

 

 

//My  problem and that puts only a h1

 

 

regards

Link to comment
https://forums.phpfreaks.com/topic/260576-extract/
Share on other sites

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.