how to scrape web page data without losing tags
问题 I am trying to scrape web data using php and dom xpath. When I store the $node->nodeValue into my database or even if i try to echo it, all the tags like <p> and <br> are missing. So I am getting all the paras concatenated. How to solve this problem 回答1: If you have a node, and you need all its contents as they are, you can use this function: function innerHTML(DOMNode $node) { $doc = new DOMDocument(); foreach ($node->childNodes as $child) { $doc->appendChild($doc->importNode($child, true));