SlideShare a Scribd company logo
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

KEY
QueryPath, Mash-ups, and Web Services
KEY
MongoDB, E-commerce and Transactions
PDF
What's brewing in the eZ Systems extensions kitchen
PPTX
JS Essence
PDF
Introduction to Python and Django
PDF
Why CouchDB
PPT
XML Amsterdam - Creating structure in unstructured data
PDF
Plone on RelStorage
QueryPath, Mash-ups, and Web Services
MongoDB, E-commerce and Transactions
What's brewing in the eZ Systems extensions kitchen
JS Essence
Introduction to Python and Django
Why CouchDB
XML Amsterdam - Creating structure in unstructured data
Plone on RelStorage

What's hot (19)

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

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

KEY
Mashups with Drupal and QueryPath
PDF
Professional XML with PHP
PDF
Unit 10: XML and Beyond (Sematic Web, Web Services, ...)
PDF
XML Tools for Perl
PPTX
Unit 3 WEB TECHNOLOGIES
PDF
XML and XPath with PHP
PDF
Os Pruett
PPT
8023.ppt
PDF
XML-Free Programming : Java Server and Client Development without &lt;>
PDF
XPath - A practical guide
PDF
Flickr Architecture Presentation
PDF
The Lumber Mill Xslt For Your Templates
PDF
Flickr Architecture Presentation
PPT
Xml 215-presentation
PDF
light_xml
PPTX
mobile computing XML_and_Mobile_Applications[1].pptx
PDF
Cutting Edge Data Processing with PHP & XQuery
PDF
Flickr and PHP - Cal Henderson
PDF
PDF
An Introduction to Basics of Search and Relevancy with Apache Solr
Mashups with Drupal and QueryPath
Professional XML with PHP
Unit 10: XML and Beyond (Sematic Web, Web Services, ...)
XML Tools for Perl
Unit 3 WEB TECHNOLOGIES
XML and XPath with PHP
Os Pruett
8023.ppt
XML-Free Programming : Java Server and Client Development without &lt;>
XPath - A practical guide
Flickr Architecture Presentation
The Lumber Mill Xslt For Your Templates
Flickr Architecture Presentation
Xml 215-presentation
light_xml
mobile computing XML_and_Mobile_Applications[1].pptx
Cutting Edge Data Processing with PHP & XQuery
Flickr and PHP - Cal Henderson
An Introduction to Basics of Search and Relevancy with Apache Solr
Ad

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