Top Banner
QueryPath It’s like PHP jQuery for Drupal http://querypath.org http://api.querypath.org Tuesday, August 17, 2010
39

QueryPath: It's like PHP jQuery in Drupal!

Nov 28, 2014

Download

Documents

Matt Butcher

This slideshow introduces QueryPath (a PHP jQuery library)
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: QueryPath: It's like PHP jQuery in Drupal!

QueryPathIt’s like PHP jQuery for Drupal

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

Tuesday, August 17, 2010

Page 2: QueryPath: It's like PHP jQuery in Drupal!

Matt ButcherMaintainer of QueryPath

Author of 6 books

Drupal developer atConsumerSearch.Com “Learning Drupal 7” will be

out in RAW this monthhttp://packtpub.com

Tuesday, August 17, 2010

Page 3: QueryPath: It's like PHP jQuery in Drupal!

Emily BrandJust completed a

GSoC QueryPath project.MA in Computer Science

IT Developer/EngineerHP

Tuesday, August 17, 2010

Page 4: QueryPath: It's like PHP jQuery in Drupal!

What Is QueryPath?

Tuesday, August 17, 2010

Page 5: QueryPath: It's like PHP jQuery in Drupal!

A PHP library for working with HTML, XML, and

Web services.

Tuesday, August 17, 2010

Page 6: QueryPath: It's like PHP jQuery in Drupal!

Follows the jQuery interfaceas much as possible.

Tuesday, August 17, 2010

Page 7: QueryPath: It's like PHP jQuery in Drupal!

Why do we need it?

Tuesday, August 17, 2010

Page 8: QueryPath: It's like PHP jQuery in Drupal!

The Task

Find all <a></a>

tags who havethe ancestor

<div></div>

Tuesday, August 17, 2010

Page 9: QueryPath: It's like PHP jQuery in Drupal!

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

Page 10: QueryPath: It's like PHP jQuery in Drupal!

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 DOMExample

Tuesday, August 17, 2010

Page 11: QueryPath: It's like PHP jQuery in Drupal!

SAX / Expat

• Event based.

• Write your own parser handler.

• One per XML format.

• Only reliable “legacy” library.

Same size,fewer features

Tuesday, August 17, 2010

Page 12: QueryPath: It's like PHP jQuery in Drupal!

QueryPath

• Compact library.

• Functions are short and mnemonic.

• The power of DOM, but simpler than SimpleXML

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

[This space intentionally left blank ]

Tuesday, August 17, 2010

Page 13: QueryPath: It's like PHP jQuery in Drupal!

Lots of Features,One function.

Tuesday, August 17, 2010

Page 14: QueryPath: It's like PHP jQuery in Drupal!

• 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);

Files, strings, objects...

Tuesday, August 17, 2010

Page 15: QueryPath: It's like PHP jQuery in Drupal!

Search with CSS

qp($rss_url, ‘item > title’);

<?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> 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

Page 16: QueryPath: It's like PHP jQuery in Drupal!

Chaining (Fluent API)

Tuesday, August 17, 2010

Page 17: QueryPath: It's like PHP jQuery in Drupal!

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

Tuesday, August 17, 2010

Page 18: QueryPath: It's like PHP jQuery in Drupal!

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

Tuesday, August 17, 2010

Page 19: QueryPath: It's like PHP jQuery in Drupal!

Some Things it Does• Import/Scrape HTML

• Read XML files

• Remote web services

• SVG image manipulation

• RSS or Atom feeds

• Retrieve database data into XML/HTML

• Work with RDFa

• Run SPARQL queries on Semantic Web

• Generate XML

• Transform using XSLT

• Interact with RDBMS

• And more...

Tuesday, August 17, 2010

Page 20: QueryPath: It's like PHP jQuery in Drupal!

QueryPath and Drupal

Tuesday, August 17, 2010

Page 21: QueryPath: It's like PHP jQuery in Drupal!

Myth“QueryPath is for Drupal”

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

Tuesday, August 17, 2010

Page 22: QueryPath: It's like PHP jQuery in Drupal!

FactThe QueryPath Drupal modules

provides all you need.

You can easily use QueryPath within Drupal.

http://drupal.org/project/querypath

Tuesday, August 17, 2010

Page 23: QueryPath: It's like PHP jQuery in Drupal!

What’s Been Done with QueryPath?

Tuesday, August 17, 2010

Page 24: QueryPath: It's like PHP jQuery in Drupal!

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

Tuesday, August 17, 2010

Page 25: QueryPath: It's like PHP jQuery in Drupal!

Tuesday, August 17, 2010

Page 26: QueryPath: It's like PHP jQuery in Drupal!

Tuesday, August 17, 2010

Page 27: QueryPath: It's like PHP jQuery in Drupal!

Tuesday, August 17, 2010

Page 28: QueryPath: It's like PHP jQuery in Drupal!

Tuesday, August 17, 2010

Page 29: QueryPath: It's like PHP jQuery in Drupal!

Tuesday, August 17, 2010

Page 30: QueryPath: It's like PHP jQuery in Drupal!

Tuesday, August 17, 2010

Page 31: QueryPath: It's like PHP jQuery in Drupal!

QueryPath 2.1

Tuesday, August 17, 2010

Page 32: QueryPath: It's like PHP jQuery in Drupal!

Better HTMLUse

htmlqp() to parse HTML.

Six lines ofcode to grab

headlines fromd.o

Tuesday, August 17, 2010

Page 33: QueryPath: It's like PHP jQuery in Drupal!

jQuery 1.4 Features• attach & detach

• has

• even & odd

• first & last

• firstChild & lastChild

• nextUntil, prevUntil & parentsUntil

• More...

Tuesday, August 17, 2010

Page 34: QueryPath: It's like PHP jQuery in Drupal!

Tons of new documentation and examples.

Tuesday, August 17, 2010

Page 35: QueryPath: It's like PHP jQuery in Drupal!

New Logo

Designed by Michael Mesker

Tuesday, August 17, 2010

Page 36: QueryPath: It's like PHP jQuery in Drupal!

And the Drupal module...

Tuesday, August 17, 2010

Page 37: QueryPath: It's like PHP jQuery in Drupal!

Drupal 7 version is DONE!

Tuesday, August 17, 2010

Page 38: QueryPath: It's like PHP jQuery in Drupal!

Demos

Tuesday, August 17, 2010

Page 39: QueryPath: It's like PHP jQuery in Drupal!

• Stable: QueryPath 2.0.1http://querypath.org

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

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

Tuesday, August 17, 2010