Thursday, 21 September 2017

php - how to separate selected tags from html content

I have an html like



 

Dr. Maria Steffens


Institute of Medico




Sta. Ana, strt PH-501


1062 Caracas


France




Telefon: +58-457-2889567


plasticsurgery@yahoo.com


www.mysite.com





Now i want to separate every tag like



Dr. Maria Steffens





or occurrence of



tag


I have tried



$html = new DOMDocument();

@$html->loadHtmlFile('http://www.sitetofetch.com');
$xpath = new DOMXPath( $html );
$nodelist = $xpath->query( "//*[@class='address']" );

foreach ($nodelist as $n){
$newhtml = $html->saveHtml($n)."\n";
$newhtml = htmlentities($newhtml);

$items = $html->getElementsByTagName('h1');
}



but its not working properly,



How can i do that.

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...