Closed GoogleCodeExporter closed 9 years ago
Getting other strange error...
Using this :
<php>$article_element->contents()->not('[nodeType=1]')->wrapInner('<p></p>');</p
hp>
I'll get this : <error>Fatal error: Call to undefined method
DOMText::getAttribute()
in phpQuery.class.php on line 2177</error>
Original comment by nicolas....@gmail.com
on 6 Oct 2008 at 3:13
In r199 filter method skips text nodes (and other non-elements). Try it now.
Original comment by tobiasz....@gmail.com
on 6 Oct 2008 at 3:25
In think I've got some error cause of the issue 49.
But I still have an error so : "Warning: Invalid argument supplied for
foreach() in
phpQuery.class.php on line 2501"
Original comment by nicolas....@gmail.com
on 6 Oct 2008 at 3:32
I've added condition to prevent foreach warning in r200. Can you check what was
selected before call to contents(), using dumpWhois() ?
Original comment by tobiasz....@gmail.com
on 7 Oct 2008 at 10:09
Doing that :
<php>
$article_element->html('hors paragraphe<p>Test</p>hors paragraphe');
foreach ($article_element->contents('not:([nodeType=1])') as $test)
{
echo "<!--\n"pQ($test)->html())."\n-->\n";
}
</php>
I'll get that :
<screen>
<br />
Warning: Invalid argument supplied for foreach() in
/x/phpQuery.class.php on line 2667<br />
<!--
-->
<!--
hors paragraphe
-->
<!--
Test
-->
<br />
Warning: Invalid argument supplied for foreach() in
/x/phpQuery.class.php on line 2667<br />
<!--
-->
</screen>
NB : cf comment 13 of issue 49
Original comment by nicolas....@gmail.com
on 12 Oct 2008 at 1:44
It seems to be the "html()" method which make the error...
Original comment by nicolas....@gmail.com
on 12 Oct 2008 at 1:45
With this DOM in my doc
<dom>
<div id="myTest"><p>hors paragraphe</p><p>Test</p>hors paragraphe</div>
</dom>
In jquery using
<js>$('#myTest').contents().not("[nodeType=1]").wrap("<p/>")</js>
change my DOM in :
<dom>
<div id="myTest"><p>hors paragraphe</p><p>Test</p><p>hors paragraphe</p></div>
</dom>
Can't reproduce it in phpQuery :(.
Original comment by nicolas....@gmail.com
on 12 Oct 2008 at 2:17
When trying to reproduce it I'll get that error :
"Fatal error: Call to undefined method DOMText::getAttribute() in
/x/phpQuery.class.php on line 2170"
Original comment by nicolas....@gmail.com
on 12 Oct 2008 at 2:40
Should be fixed in r202. Last fix was in wrong loop, but should display a
notice...
Original comment by tobiasz....@gmail.com
on 16 Oct 2008 at 12:19
Working... or something like
Having the dom :
<dom>
<div id="#myDiv">
hors paragraphe
<p>Test</p>
hors paragraphe
</div>
</dom>
Doing that :
<php>$myPhpQueryElement->find('#myDiv')->append('hors paragraphe<p>Test</p>hors
paragraphe')->contents()->not('[nodeType=1]')->wrap('<p/>');</php>
Give me the DOM :
<dom>
<div id="#myDiv">
<p/>
<p>hors paragraphe</p>
<p/>
<p>Test</p>
<p>hors paragraphe</p>
</div>
</dom>
So there's two empty P element wraping the first P element.
On the same thing jQuery give me that DOM :
<dom>
<div id="#myDiv">
<p>hors paragraphe</p>
<p>Test</p>
<p>hors paragraphe</p>
</div>
</dom>
Original comment by nicolas....@gmail.com
on 16 Oct 2008 at 8:59
nodeType or any other not-direct attributes aren't supported right now. This
means
->not('[nodeType=1]') dont do anything. I've created new issue for this
functionality:
http://code.google.com/p/phpquery/issues/detail?id=61
Have you tested r202 ? Using code below:
$doc = phpQuery::newDocumentHTML('<div id="myDiv"></div>');
$doc['#myDiv']->append('hors paragraphe<p>Test</p>hors paragraphe')
->contents()
->not('[nodeType=1]')
->wrap('<p/>');
I have (in r202):
<div id="myDiv">
<p>hors paragraphe</p>
<p><p>Test</p></p>
<p>hors paragraphe</p>
</div>
Which is expected output (considering no nodeType support).
Original comment by tobiasz....@gmail.com
on 16 Oct 2008 at 9:27
Using the same DOM and :
<php>
$article_element->contents()->not('[nodeType=1]')->wrap('<p/>')->children('p:emp
ty')->remove();
</php>
It display me the error :
"
Fatal error: Call to undefined method DOMText::getElementsByTagName() in
/x/phpQueryObject.php on line 1618"
Original comment by nicolas....@gmail.com
on 16 Oct 2008 at 2:12
Related to Issue #61 - no DOMNode support other than nodeType = 1 (DOMElement,
normal
tags). Result of contents() can lead to such errors.
Original comment by tobiasz....@gmail.com
on 18 Oct 2008 at 8:56
Original issue reported on code.google.com by
nicolas....@gmail.com
on 6 Oct 2008 at 2:59