Using PHP and preg_match_all I\'m trying to get all the HTML content between the following tags (and the tags also):
paragraph text
don\'t
If you are to use a DOM parser, and you should, here's how. A contributor posted a useful function for obtaining a DOMNode's innerHTML, which I will use in the following example:
$dom = new DOMDocument;
$dom->loadHTML($html);
$p = $dom->getElementsByTagName('p')->item(0); // first node
$ul = $dom->getElementsByTagName('ul')->item(0); // first
node
$table = $dom->getElementsByTagName('table')->item(0); // first node
echo DOMinnerHTML($p);
echo DOMinnerHTML($ul);
echo DOMinnerHTML($table);
- 热议问题