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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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