-
Notifications
You must be signed in to change notification settings - Fork 16
No pissibility to use libxml options in loadHTML #15
Comments
@step307 Thanks! |
@froschdesign , exactly in my case I want to parse and modify pieces of HTML, not the whole document. Default behavior is, that DomDocument always adds "missing" and tags, which is absolutely undesired. LIBXML_HTML_NOIMPLIED exactly "turns off the automatic adding of implied html/body... elements" There are a lot of other options which definitely make sense. Full list: http://php.net/manual/en/libxml.constants.php |
I know this, but it doesn't matter. What is the concrete problem. Can you provide a short example which illustrate the problem and why the current implementation does not work? And again: the class is named |
This is not a bug report, but a feature request. There is no problem and everything surely works as designed. P.S. I don't find any Fragment or Partial in this module and therefore make a proposal for existing Document. |
@step307 $results = Zend\Dom\Document\Query::execute(
'.block__headline',
new Zend\Dom\Document(
'<div class="block"><h1 class="block__headline">Foobar</h1></div>'
),
Zend\Dom\Document\Query::TYPE_CSS
);
var_dump(count($results)); // 1 If we extend the component to support the additional Libxml parameters, where is the benefit? |
@froschdesign , as I wrote I need to parse and modify a piece of HTML. Here is small illustration: Imagine you want to update title in your example: $document = new \Zend\Dom\Document(
'<div class="block"><h1 class="block__headline">Foobar</h1></div>'
);
$results = \Zend\Dom\Document\Query::execute(
'.block__headline',
$document,
\Zend\Dom\Document\Query::TYPE_CSS
);
$results->current()->textContent = 'Foobar2';
var_dump($document->getDomDocument()->saveHTML()); you will get extra DOCTYPE, html and body tags in the result. |
This repository has been closed and moved to laminas/laminas-dom; a new issue has been opened at laminas/laminas-dom#2. |
This is a feature request.
Accordingly to:
zend-dom/src/Document.php
Line 254 in 245d75d
loadHTML is called without any options and there is no way to configure them.
Exactly in my case, I'm missing LIBXML_HTML_NOIMPLIED to operate partial HTMLs
The text was updated successfully, but these errors were encountered: