By Matt Butcher
QueryPath 2.0 Alpha 2
Submitted by matt on Mon, 2009-06-15 19:04
QueryPath Alpha 2 is now available.
The following major changes were made in Alpha 2:
- The QueryPathImpl class has been re-named QueryPath. The QueryPath interface has been removed.
- The file QueryPathImpl.php has been merged with the file QueryPath.php, and the interface has been removed from QueryPath.php
- This version adds support for selectors as an argument to
branch(). - Bug Fix: When a selector that contained only an '#id' was executed and no such id was found, old matches were incorrectly returned. (Reported by Ryan Mahoney).
Only a few more changes are likely to come along before we switch from Alpha to Beta releases.
Please report bugs here: http://github.com/technosophos/querypath/issues








XML Namespace Issue in QueryPath?
Hi Matt,
Im doing this with QueryPath:
$url = url('http://blogs.cisco.com/rss/news/#', array('absolute' => TRUE));
foreach (qp($url, 'item') as $item) {
$title = $item->find('title')->text();
$link = $item->next('link')->text();
$descr = $item->next('description')->text();
$date = $item->next('dc:date')->text();
$out .= '<p>' . l($title, $link) . '</p><br><p>' . $descr . '<br>' . $date . '</p>';
}
It works fine as long as I dont try to pull the date...
but it wont work with the COLON in dc:date... how do we handle XML tags with Dublin Core namespace identifiers?
This was an issue in jQuery also that people seemed to fix by escaping the colon with \ - but that didnt work here for me.. tried to quote it all ways I could think of
Can you assist?
Old Jquery issue as reference:
http://dev.jquery.com/ticket/155
This is a very cool capability that I found last night while searching for Drupal Quiz information last night... excited to see where you take this!
Cheers,
Ken
Namespaces in QueryPath
This is one area where QueryPath is (by necessity) ahead of jQuery. QueryPath has full standards compliant support for XML namespaces. The only problem is... the standard is weird, and less than obvious.
Per the CSS 3 spec, namespace queries have to look like this:
dc|dateThe colon is replaced with a vertical bar in a CSS 3 Selector.
So simply change your code to do this should work:
$date = $item->next('dc|date')->text();You can see an example of this in a recent post (http://technosophos.com/content/reading-odt-files-querypath) or in the examples/ folder of the full QueryPath distribution. The Drupal QueryPath module also includes some examples that use namespaced queries to handle RDF data.
That one didnt work for me...
Hi Matt,
The deeper I dive into the Drupal hole... I see more and more of your name. So, I have to say thanks again - you are enabling some pretty cool stuff that I think will make the Internet a much better place.
Unfortunately, I had already found the page you referenced and tried that one... dc|date didnt work either (though it was safely ignored and page rendered).
Here is my code if you want to try it yourself... just a cut and paste of your example really.
$url = url('http://blogs.cisco.com/rss/news/#', array('absolute' => TRUE)); foreach (qp($url, 'item') as $item) { $title = $item->find('title')->text(); $link = $item->next('link')->text(); $descr = $item->next('description')->text(); $date = $item->next('dc|date')->text(); $out .= '<p>' . l($title, $link) . '<hr size=2px style="color:#8dbc56; padding:0px; margin:0px">'; $out .= '</p><br><p>' . $descr . '<br>' . $date . '</p>'; $out .= '<hr size=2px style="color:#8dbc56; padding:0px; margin:0px">'; }Ken
Try this one.
I just tried this (minor tweaks from your code above, since I am testing outside of Drupal), and it works:
Notice that the dc|date stuff is the same. It gives me output like this:
123
大人のおもちゃ
太陽光発電 比較
karibiann
sem研究会
無料ブログ
SEOの間違い探し
ロングテールSEO
住宅パース
GoogleのSEO対策
薬剤師 転職
YahooのSEO
太陽光発電で快適ライフ
アダルトグッズ
失敗する方
固定コンテンツサイト
アダルトグッズ
アダルトグッズ
京セラ
cgパース
お勧め大人のおもちゃ
鶯谷韓国
太陽光発電
事業再生
建築
薬剤師 求人
モバイルブログ
大人のおもちゃ
建築パース
住宅パース
SEO成功
天然素材
SEOの情勢
マンションリフォーム
競馬予想
風俗
GoogleのSEO
出会いたい
オール電化住宅
建築模型製作
ブログスパム
Post new comment