Wednesday 5 April 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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...