There was an error in this gadget

Saturday, January 24, 2009

QueryPath: It's like jQuery PHP.

I have just posted "my winter project." Its name is QueryPath, and it's something like jQuery PHP (or is that PHP jQuery?).

While writing the Drupal 6, JavaScript, and jQuery book, I started looking for something like jQuery in the PHP world. I found several projects that implemented small subsets of the jQuery API, but nothing approaching the complexity I had in mind.

So I went back a step, and started looking for a good CSS 3 Selector implementation. I didn't find one of those, either. At best, I found some simple regex-style tools that supported a small portion of the CSS 3 Selector standard.

There was nothing else to do but start coding.

First I wrote a recursive descent parser for CSS 3, including support for XML namespaces and other ill-defined yuckiness.

Then I wrote an event-based API similar to SAX2 -- only for CSS 3 Selectors. And I wrote an implementation of the API.

From there, I began constructing a PHP equivalent of jQuery. Not all of the jQuery API is relevant in PHP. After all, an event model glue layer is not of general interest in a single-threaded PHP app. But HTML/XML traversing and manipulating certainly are. So I borrowed as much of the jQuery API as seemed appropriate.

While I used the same function names (except for empty, which is a PHP reserved word), and tried to follow as closely as possible in parameters and return values, the internals are almost completely different. Why not? After all, JavaScript and PHP are very different languages.

The coding process was interesting. I'm too busy to write something like this in one go. So I spread it out... in 15-30 minute increments. In fact, I developed most of QueryPath while riding Chicagoland trains to and from work. Even with this bizarre and disjointed development path, I eventually finished. QueryPath's main library has 58 public methods, almost all of which are from jQuery's API (though I added some, like an XPath query and tools to use PHP delta and callback functions).

But I wasn't happy. I wanted some cool extensions (plugins), too. It didn't take me long to figure out the obvious: QueryPath needed a database layer. Using PHP's PDO library, I constructed a simple database library, QPDB, that allowed various ways of merging SQL results into XML/HTML. Take a query and turn it into a table or a list. Or get get more detailed -- you can put database results (in whole or in part) wherever you want! There's even a simple template language (I like to call it HTML) that you can use to format results in sophisticated ways.

I am so happy with the library that I have released it under LGPL or MIT License (your choice). You can head over to QueryPath.org (or skip straight to the downloads and docs at http://fedorahosted.org/querypath) to try it out for yourself.)

N.B. A huge thanks to the Fedora Hosted folks for (a) inviting me to host there, (b) providing an unbelievable array of VCS and bug tracking tools, and (c) being more than congenial all along.

813 comments:

«Oldest   ‹Older   801 – 813 of 813
ahmad zainuddin said...

Great information, dont forget to visit our website :)
Pengertian Komplit

Unknown said...

Thank's a lot for your information

Pakar Makalah

Unknown said...


nice info you got there, i found this site from my friend computer and good things this is a good site dewa poker

Unknown said...


nice info you got there, i found this site from my friend computer and good things this is a good site dewa poker

Lonzo Paul said...

Really love your site, thank you for sharing!

https://www.redbubble.com/people/anthonysudjono
https://audioboom.com/users/4980084
https://www.programmableweb.com/profile/anthonysudjono
https://www.sitejabber.com/reviews/www.goldewa.com#1
http://www.infobarrel.com/Users/anthonysudjono

Lonzo Paul said...

Thank you so much for sharing, love your post!

Really love your site, i will bookmark it!

http://rdbl.co/2wFavyx
http://bit.ly/2gKqM1A
http://bit.ly/2j1YoIY
http://bit.ly/2w4Qvnp
http://bit.ly/2vKnpy9

Lonzo Paul said...

I have share it to my friend and they love it!

http://rdbl.co/2vKhg56
http://bit.ly/2wEIJUP
http://bit.ly/2f1MZEy
http://bit.ly/2gLFW6s
http://bit.ly/2vK5fwD

apps download said...

phoneme download
Blue Whale Apk Download
Blue Whale Challenging
Blue Whale Challenging
Blue Whale Challenging
Blue Whale Challenging
Blue Whale Challenging
Blue Whale Challenging
Blue Whale Challenging



Download WhatsApp 2018
Download WhatsApp 2018
Download WhatsApp 2018
Download WhatsApp 2018
Download WhatsApp 2018
Download WhatsApp 2018
Download WhatsApp 2018
Download WhatsApp 2018

Rahmat said...

Tempat Nonton TV Online Indonesia Live Streaming Gratis

Jamu Herbal Indonesia said...

Pusat Jamu Herbal Indonesia yang menjual obat-obatan herbal Original HALAL dan Legal DEPKES serta BPOM RI

apps download said...

Download WhatsApp 2018
WhatsApp 2018
Download WhatsApp APK 2018
Free Download WhatsApp 2018
Download WhatsApp 2018
Download WhatsApp 2018
Download WhatsApp 2018
Download WhatsApp 2018

4Share Info Tv said...

Cara download lagu di youtube dalam format MP3 ini sebenarnya ditujukan untuk video-video lagu dan musik saja. Kalau teman-teman menemukan lagu atau musik yang disukai, maka bisa di download dalam bentuk file mp3 saja.

Jadi berbeda dengan artikel sebelumnya yang membahas tentang cara download video youtube tanpa software, karena metode itu download audio dan video, sedang metode ini hanya download mp3 aja...

Contoh kasus yang paling membutuhkan metode ini, anggap saja anda seorang dancer dan sedang menyaksikan suatu video dancer yang anda sukai musiknya, maka anda bisa mendownload musiknya saja untuk dipakai mengembangkan tarian anda. Musik ini akan diformat ulang dulu ke dalam format MP3 sebelum bisa anda download.

Krystal Fransisco said...

Suka Baca Cerita Dewasa, Suka Nonton Video Bokep di sini aja, Klik : Cerita Dewasa

«Oldest ‹Older   801 – 813 of 813   Newer› Newest»