SlideShare a Scribd company logo
1 of 39
Download to read offline
QueryPath
                           It’s like PHP jQuery for Drupal


                               http://querypath.org
                             http://api.querypath.org



Tuesday, August 17, 2010
Matt Butcher
                 Maintainer of QueryPath

                           Author of 6 books

                    Drupal developer at
                   ConsumerSearch.Com          “Learning Drupal 7” will be
                                                 out in RAW this month
                                                 http://packtpub.com
Tuesday, August 17, 2010
Emily Brand
                  Just completed a
               GSoC QueryPath project.
               MA in Computer Science

                   IT Developer/Engineer
                            HP



Tuesday, August 17, 2010
What Is QueryPath?



Tuesday, August 17, 2010
A PHP library for working with
                                 HTML, XML, and
                                   Web services.




Tuesday, August 17, 2010
Follows the jQuery interface
                                as much as possible.




Tuesday, August 17, 2010
Why do we need it?



Tuesday, August 17, 2010
The Task
                       Find all
                     <a></a>
                   tags who have
                    the ancestor
                   <div></div>




Tuesday, August 17, 2010
The DOM API
                    •      At least seventeen
                           classes, each with dozens
                           of methods.

                    •      Complex data structure.

                    •      Checkered history in
                           PHP.

                    •      VERY powerful.




Tuesday, August 17, 2010
SimpleXML

                    •      One class, about a dozen
                           functions and methods.

                    •      Turns XML into basic
                           objects.

                    •      Makes easy stuff easy,
                           and makes everything
                           else insanely hard.
                                         Same size as DOM
                                             Example


Tuesday, August 17, 2010
SAX / Expat
                                      Same size,
                                    fewer features


                    •      Event based.

                    •      Write your own parser
                           handler.

                    •      One per XML format.

                    •      Only reliable “legacy”
                           library.




Tuesday, August 17, 2010
QueryPath
                    •      Compact library.

                    •      Functions are short and
                           mnemonic.
                                                           [This space intentionally left blank ]
                    •      The power of DOM, but
                           simpler than SimpleXML

                    •      (Shhh... don’t tell, but it’s
                           built on the DOM.)




Tuesday, August 17, 2010
Lots of Features,
                            One function.


Tuesday, August 17, 2010
Files, strings, objects...

                    • Open XML/HTML file: qp(‘somefile.xml’);
                    • Parse string: qp(‘<html>...</html>’);
                    • Get URL: qp(‘http://drupal.org');
                    • Use DOM or SimpleXML object: qp($ele);

Tuesday, August 17, 2010
Search with CSS
    <?xml version="1.0" encoding="utf-8"?>
    <rss xmlns:dc="http://purl.org/dc/elements/1.1/"
       version="2.0" xml:base="http://technosophos.com">
     <channel>
       <title>TechnoSophos</title>
       <link>http://technosophos.com</link>
       <item>
        <title>
                                                  qp($rss_url, ‘item > title’);
          Drupal Dojo: "QueryPath"
        </title>
        <link>http://technosophos.com/content/...</link>
        <description>
          On August 17th at 12pm EDT (9AM PDT)...
        </description>
       </item>
     </channel>
    </rss>




Tuesday, August 17, 2010
Chaining (Fluent API)



Tuesday, August 17, 2010
$qp = new QueryPath(‘my.xml’);
                           $qp->find(‘root’);
                           $qp->append(‘<p>Hi.</p>’)




Tuesday, August 17, 2010
qp(‘my.xml’, ‘root’)->append(‘<p>Hi.</p>’);




Tuesday, August 17, 2010
Some Things it Does
                    •      Import/Scrape HTML       •   Work with RDFa

                    •      Read XML files            •   Run SPARQL queries on
                                                        Semantic Web
                    •      Remote web services
                                                    •   Generate XML
                    •      SVG image manipulation
                                                    •   Transform using XSLT
                    •      RSS or Atom feeds
                                                    •   Interact with RDBMS
                    •      Retrieve database data
                           into XML/HTML            •   And more...


Tuesday, August 17, 2010
QueryPath and Drupal



Tuesday, August 17, 2010
Myth
               “QueryPath is for Drupal”

         QueryPath is a PHP library, and
         will work with any PHP tool.*




Tuesday, August 17, 2010
Fact
        The QueryPath Drupal modules
            provides all you need.

           You can easily use QueryPath
                  within Drupal.


                           http://drupal.org/project/querypath
Tuesday, August 17, 2010
What’s Been Done
                           with QueryPath?


Tuesday, August 17, 2010
Honestly, I can’t keep track anymore.
                              But here are a few examples.




Tuesday, August 17, 2010
Tuesday, August 17, 2010
Tuesday, August 17, 2010
Tuesday, August 17, 2010
Tuesday, August 17, 2010
Tuesday, August 17, 2010
Tuesday, August 17, 2010
QueryPath 2.1



Tuesday, August 17, 2010
Six lines of
                      code to grab
                     headlines from
                           d.o



             Better HTML
                                 Use
                             htmlqp()
                           to parse HTML.




Tuesday, August 17, 2010
jQuery 1.4 Features
                    •      attach & detach

                    •      has

                    •      even & odd

                    •      first & last

                    •      firstChild & lastChild

                    •      nextUntil, prevUntil &
                           parentsUntil

                    •      More...

Tuesday, August 17, 2010
Tons of new documentation and examples.




Tuesday, August 17, 2010
New Logo




                           Designed by Michael Mesker

Tuesday, August 17, 2010
And the Drupal
                             module...


Tuesday, August 17, 2010
Drupal 7 version is DONE!




Tuesday, August 17, 2010
Demos




Tuesday, August 17, 2010
• Stable: QueryPath 2.0.1
                           http://querypath.org

                    • Development: QueryPath 2.1
                           http://github.com/technosophos/querypath

                    • Drupal modules at
                           http://drupal.org/project/querypath




Tuesday, August 17, 2010

More Related Content

What's hot

Enterprise search in plone using solr
Enterprise search in plone using solrEnterprise search in plone using solr
Enterprise search in plone using solr
Calvin Hendryx-Parker
 
ePUB in brief
ePUB in briefePUB in brief
ePUB in brief
Sean Lee
 
NoSQL: Why, When, and How
NoSQL: Why, When, and HowNoSQL: Why, When, and How
NoSQL: Why, When, and How
BigBlueHat
 
NoSQL in Perspective
NoSQL in PerspectiveNoSQL in Perspective
NoSQL in Perspective
Jeff Smith
 

What's hot (19)

MongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combinationMongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combination
 
XFILES, The APEX 4 version - The truth is in there
XFILES, The APEX 4 version - The truth is in thereXFILES, The APEX 4 version - The truth is in there
XFILES, The APEX 4 version - The truth is in there
 
Parsing XML & JSON in Apex
Parsing XML & JSON in ApexParsing XML & JSON in Apex
Parsing XML & JSON in Apex
 
Extbase object to xml mapping
Extbase object to xml mappingExtbase object to xml mapping
Extbase object to xml mapping
 
Enterprise search in plone using solr
Enterprise search in plone using solrEnterprise search in plone using solr
Enterprise search in plone using solr
 
Drupal8 themingdeepdive drupaldevdays-montpellier17042015
Drupal8 themingdeepdive drupaldevdays-montpellier17042015Drupal8 themingdeepdive drupaldevdays-montpellier17042015
Drupal8 themingdeepdive drupaldevdays-montpellier17042015
 
A rubyist's naive comparison of some database systems and toolkits
A rubyist's naive comparison of some database systems and toolkitsA rubyist's naive comparison of some database systems and toolkits
A rubyist's naive comparison of some database systems and toolkits
 
ePUB in brief
ePUB in briefePUB in brief
ePUB in brief
 
Day 2 - Intro to Rails
Day 2 - Intro to RailsDay 2 - Intro to Rails
Day 2 - Intro to Rails
 
PyCon 2011 Scaling Disqus
PyCon 2011 Scaling DisqusPyCon 2011 Scaling Disqus
PyCon 2011 Scaling Disqus
 
Enterprise search in Plone using Solr
Enterprise search in Plone using SolrEnterprise search in Plone using Solr
Enterprise search in Plone using Solr
 
NoSQL: Why, When, and How
NoSQL: Why, When, and HowNoSQL: Why, When, and How
NoSQL: Why, When, and How
 
NoSQL for great good [hanoi.rb talk]
NoSQL for great good [hanoi.rb talk]NoSQL for great good [hanoi.rb talk]
NoSQL for great good [hanoi.rb talk]
 
Day 1 - Intro to Ruby
Day 1 - Intro to RubyDay 1 - Intro to Ruby
Day 1 - Intro to Ruby
 
BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server
BGOUG 2012 - Drag & drop and other stuff - Using your database as a file serverBGOUG 2012 - Drag & drop and other stuff - Using your database as a file server
BGOUG 2012 - Drag & drop and other stuff - Using your database as a file server
 
NoSQL in Perspective
NoSQL in PerspectiveNoSQL in Perspective
NoSQL in Perspective
 
Restful Best Practices
Restful Best PracticesRestful Best Practices
Restful Best Practices
 
NoSQL into E-Commerce: lessons learned
NoSQL into E-Commerce: lessons learnedNoSQL into E-Commerce: lessons learned
NoSQL into E-Commerce: lessons learned
 
Elasticsearch: You know, for search! and more!
Elasticsearch: You know, for search! and more!Elasticsearch: You know, for search! and more!
Elasticsearch: You know, for search! and more!
 

Similar to QueryPath: It's like PHP jQuery in Drupal!

Document-Oriented Databases: Couchdb Primer
Document-Oriented Databases: Couchdb PrimerDocument-Oriented Databases: Couchdb Primer
Document-Oriented Databases: Couchdb Primer
jsiarto
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Guillaume Laforge
 
Los Angeles R users group - Nov 17 2010 - Part 2
Los Angeles R users group - Nov 17 2010 - Part 2Los Angeles R users group - Nov 17 2010 - Part 2
Los Angeles R users group - Nov 17 2010 - Part 2
rusersla
 
IPTC News in JSON Spring 2013
IPTC News in JSON Spring 2013IPTC News in JSON Spring 2013
IPTC News in JSON Spring 2013
Stuart Myles
 

Similar to QueryPath: It's like PHP jQuery in Drupal! (20)

Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
 
Is these a bug
Is these a bugIs these a bug
Is these a bug
 
Not Only Drupal
Not Only DrupalNot Only Drupal
Not Only Drupal
 
Mashups with Drupal and QueryPath
Mashups with Drupal and QueryPathMashups with Drupal and QueryPath
Mashups with Drupal and QueryPath
 
Document-Oriented Databases: Couchdb Primer
Document-Oriented Databases: Couchdb PrimerDocument-Oriented Databases: Couchdb Primer
Document-Oriented Databases: Couchdb Primer
 
WordPress Front End Optimizations
WordPress Front End OptimizationsWordPress Front End Optimizations
WordPress Front End Optimizations
 
Edted 2010 Ruby on Rails
Edted 2010 Ruby on RailsEdted 2010 Ruby on Rails
Edted 2010 Ruby on Rails
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
 
Los Angeles R users group - Nov 17 2010 - Part 2
Los Angeles R users group - Nov 17 2010 - Part 2Los Angeles R users group - Nov 17 2010 - Part 2
Los Angeles R users group - Nov 17 2010 - Part 2
 
Mathias test
Mathias testMathias test
Mathias test
 
Building Distributed JavaScript Widgets with jQuery
Building Distributed JavaScript Widgets with jQueryBuilding Distributed JavaScript Widgets with jQuery
Building Distributed JavaScript Widgets with jQuery
 
noSQL @ QCon SP
noSQL @ QCon SPnoSQL @ QCon SP
noSQL @ QCon SP
 
IPTC News in JSON Spring 2013
IPTC News in JSON Spring 2013IPTC News in JSON Spring 2013
IPTC News in JSON Spring 2013
 
XQuery Design Patterns
XQuery Design PatternsXQuery Design Patterns
XQuery Design Patterns
 
GGUG:Practical DSL Design
GGUG:Practical DSL DesignGGUG:Practical DSL Design
GGUG:Practical DSL Design
 
In depth with html5 java2days 2010
In depth with html5 java2days 2010In depth with html5 java2days 2010
In depth with html5 java2days 2010
 
MongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema DesignMongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema Design
 
Persistence Smoothie: Blending SQL and NoSQL (RubyNation Edition)
Persistence  Smoothie: Blending SQL and NoSQL (RubyNation Edition)Persistence  Smoothie: Blending SQL and NoSQL (RubyNation Edition)
Persistence Smoothie: Blending SQL and NoSQL (RubyNation Edition)
 
BRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLBRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQL
 
iBizLog. Smalltalking the Web
iBizLog. Smalltalking the WebiBizLog. Smalltalking the Web
iBizLog. Smalltalking the Web
 

QueryPath: It's like PHP jQuery in Drupal!

  • 1. QueryPath It’s like PHP jQuery for Drupal http://querypath.org http://api.querypath.org Tuesday, August 17, 2010
  • 2. Matt Butcher Maintainer of QueryPath Author of 6 books Drupal developer at ConsumerSearch.Com “Learning Drupal 7” will be out in RAW this month http://packtpub.com Tuesday, August 17, 2010
  • 3. Emily Brand Just completed a GSoC QueryPath project. MA in Computer Science IT Developer/Engineer HP Tuesday, August 17, 2010
  • 4. What Is QueryPath? Tuesday, August 17, 2010
  • 5. A PHP library for working with HTML, XML, and Web services. Tuesday, August 17, 2010
  • 6. Follows the jQuery interface as much as possible. Tuesday, August 17, 2010
  • 7. Why do we need it? Tuesday, August 17, 2010
  • 8. The Task Find all <a></a> tags who have the ancestor <div></div> Tuesday, August 17, 2010
  • 9. The DOM API • At least seventeen classes, each with dozens of methods. • Complex data structure. • Checkered history in PHP. • VERY powerful. Tuesday, August 17, 2010
  • 10. SimpleXML • One class, about a dozen functions and methods. • Turns XML into basic objects. • Makes easy stuff easy, and makes everything else insanely hard. Same size as DOM Example Tuesday, August 17, 2010
  • 11. SAX / Expat Same size, fewer features • Event based. • Write your own parser handler. • One per XML format. • Only reliable “legacy” library. Tuesday, August 17, 2010
  • 12. QueryPath • Compact library. • Functions are short and mnemonic. [This space intentionally left blank ] • The power of DOM, but simpler than SimpleXML • (Shhh... don’t tell, but it’s built on the DOM.) Tuesday, August 17, 2010
  • 13. Lots of Features, One function. Tuesday, August 17, 2010
  • 14. Files, strings, objects... • Open XML/HTML file: qp(‘somefile.xml’); • Parse string: qp(‘<html>...</html>’); • Get URL: qp(‘http://drupal.org'); • Use DOM or SimpleXML object: qp($ele); Tuesday, August 17, 2010
  • 15. Search with CSS <?xml version="1.0" encoding="utf-8"?> <rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0" xml:base="http://technosophos.com"> <channel> <title>TechnoSophos</title> <link>http://technosophos.com</link> <item> <title> qp($rss_url, ‘item > title’); Drupal Dojo: "QueryPath" </title> <link>http://technosophos.com/content/...</link> <description> On August 17th at 12pm EDT (9AM PDT)... </description> </item> </channel> </rss> Tuesday, August 17, 2010
  • 17. $qp = new QueryPath(‘my.xml’); $qp->find(‘root’); $qp->append(‘<p>Hi.</p>’) Tuesday, August 17, 2010
  • 19. Some Things it Does • Import/Scrape HTML • Work with RDFa • Read XML files • Run SPARQL queries on Semantic Web • Remote web services • Generate XML • SVG image manipulation • Transform using XSLT • RSS or Atom feeds • Interact with RDBMS • Retrieve database data into XML/HTML • And more... Tuesday, August 17, 2010
  • 20. QueryPath and Drupal Tuesday, August 17, 2010
  • 21. Myth “QueryPath is for Drupal” QueryPath is a PHP library, and will work with any PHP tool.* Tuesday, August 17, 2010
  • 22. Fact The QueryPath Drupal modules provides all you need. You can easily use QueryPath within Drupal. http://drupal.org/project/querypath Tuesday, August 17, 2010
  • 23. What’s Been Done with QueryPath? Tuesday, August 17, 2010
  • 24. Honestly, I can’t keep track anymore. But here are a few examples. Tuesday, August 17, 2010
  • 32. Six lines of code to grab headlines from d.o Better HTML Use htmlqp() to parse HTML. Tuesday, August 17, 2010
  • 33. jQuery 1.4 Features • attach & detach • has • even & odd • first & last • firstChild & lastChild • nextUntil, prevUntil & parentsUntil • More... Tuesday, August 17, 2010
  • 34. Tons of new documentation and examples. Tuesday, August 17, 2010
  • 35. New Logo Designed by Michael Mesker Tuesday, August 17, 2010
  • 36. And the Drupal module... Tuesday, August 17, 2010
  • 37. Drupal 7 version is DONE! Tuesday, August 17, 2010
  • 39. • Stable: QueryPath 2.0.1 http://querypath.org • Development: QueryPath 2.1 http://github.com/technosophos/querypath • Drupal modules at http://drupal.org/project/querypath Tuesday, August 17, 2010