DiDom\Document::html PHP Method

html() public method

Dumps the internal document into a string using HTML formatting.
public html ( integer $options = LIBXML_NOEMPTYTAG ) : string
$options integer Additional options
return string The document html
    public function html($options = LIBXML_NOEMPTYTAG)
    {
        return trim($this->document->saveXML($this->getElement(), $options));
    }

Usage Example

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $container = $this->getContainer();
     $em = $container->get('doctrine')->getManager();
     //$utils = $container->get('sbranch.common.utils');
     $items = $em->getRepository("AppBundle:Item")->findTimed();
     $output->writeln('Total count items ' . sizeof($items));
     $progress = new ProgressBar($output, sizeof($items));
     $progress->start();
     foreach ($items as $item) {
         $progress->advance();
         //            if($item->getHtmlDocument()) {
         //                $document = new Document();
         //                $document->loadHtml($item->getHtmlDocument());
         //            } else {
         //
         //            }
         $document = new Document($item->getUrl(), true);
         $title = $document->find('title');
         //TODO: this parsing is shitcode
         $piecesTitle = explode(":", $title[0]->text());
         $piecesTitle2 = explode('-', trim(end($piecesTitle)));
         $priceString = trim($piecesTitle2[0]);
         $pricePieces = explode(' ', $priceString);
         $currency = trim(end($pricePieces));
         $price = trim(str_replace($currency, '', $priceString));
         $price = trim(str_replace(' ', '', $price));
         $title = $piecesTitle[0];
         $item->setTitle($title);
         if ($price != $item->getPrice()) {
             $item->setPriceOld($item->getPrice());
         }
         $item->setPrice($price);
         $item->setCurrency($currency);
         $item->setLastCheck(new \DateTime());
         $item->setHtmlDocument($document->html());
         $em->persist($item);
     }
     $progress->finish();
     $em->flush();
     $output->writeln('Ok');
 }
All Usage Examples Of DiDom\Document::html