esafwan - you can use a regex expression to extract content between a div (specific identifier).
I already did this for image tags, so the same rules apply. I will watch the code and update the message a bit.
[update] try the following:
<?php function get_tag( $attr, $value, $xml ) { $attr = preg_quote($attr); $value = preg_quote($value); $tag_regex = '/<div[^>]*'.$attr.'="'.$value.'">(.*?)<\\/div>/si'; preg_match($tag_regex, $xml, $matches); return $matches[1]; } $yourentirehtml = file_get_contents("test.html"); $extract = get_tag('id', 'content', $yourentirehtml); echo $extract; ?>
or more simply:
preg_match("/<div[^>]*id=\"content\">(.*?)<\\/div>/si", $text, $match); $content = $match[1];
Jim
source share