Parsing HTML with formatted text

Viewed 233

I'm parsing an HTML web page with DOMDocument.

Here is my code:

$doc = new DOMDocument();
$doc->strictErrorChecking = false;
$input = file_get_contents($url); //Url passato come parametro
$doc->loadHTML( $input );
$xpath = new DOMXpath($doc);
$article = $xpath->query('//div[@class="entry-container fix"]');

In $article I have all text inside a "entry-container fix" Div.

But this text in the web page have a formatted text. Simply expample:

<div> 
   <p> Text <strong> Strong text </strong> </p>
</div>

With my code, I lost all bold, italian characters, all paragraphs ecc... There's a way to get all formatted text?

1 Answers
Related