I want to selecting an XML node based on whether it has a child with a URL attribute set to a certain value.
I think this code shows phpQuery doesn't parse URL correctly... but I may have missed something regarding escaping the =...
Any ideas?
<?php
include '../libs/phpQuery.php';
phpQuery::newDocumentXML('
<doc><item>item 1<link url="http://example.com" /></item>
<item>item 2<link url="http://example.com?abc" /></item>
<item>item 3<link url="http://example.com?abc=" /></item>
<item>item 4<link url="http://example.com?abc=21" /></item>
</doc>');
echo "<pre>
".
pq("link[url='http://example.com']:first")->parents('item')->xml()
."
".
pq("link[url='http://example.com?abc']:first")->parents('item')->xml()
."
".
pq("link[url='http://example.com?abc=']:first")->parents('item')->xml()
."
".
pq("link[url='http://example.com?abc=21']:first")->parents('item')->xml()
."
</pre>";
?>
This is returning
<pre>
item 1<link url="http://example.com"/>
item 2<link url="http://example.com?abc"/>
item 2<link url="http://example.com?abc"/>
item 2<link url="http://example.com?abc"/>
</pre>
:firstis supposed to dolink's are:firstand:lastas well as:only-child, do you see why?