2007 Barcelona Drupalcon: Drupal and SimpleXML

73 %
27 %
Information about 2007 Barcelona Drupalcon: Drupal and SimpleXML

Published on September 25, 2007

Author: walkah

Source: slideshare.net

Drupal and SimpleXML

XML parsing • Very well defined, well known standards • Excellent support ... • ... in most other languages • Long-standing PHP weakness (up to version 4)

two main models


Simple API for XML • Stream - based xml parsing • Event - driven API • Uni-directional


Document Object Model • Full object representation of an XML document • Supports writing documents • Same system used by browsers, javascript, etc (i.e. “known quantity”)

Other key concepts • Namespaces: Allow extending existing XML documents • XPath: selector syntax for addressing parts of a document • XSLT: “template” language for transforming XML documents into other formats

DOM in PHP • http://php.net/domxml • Traditionally required external libraries and additional PHP compile flags • Has been removed from PHP core in PHP5 (available as a PECL module) • not really an option for Drupal core

SAX in PHP • Available in PHP 4 & PHP 5 ( --with-xml ) • Closest “built-in” support • (hence what we use in Drupal) • http://php.net/xml

SAX example

SAX example (cont.)

SAX example (cont)

SAX example (cont)

SAX drawbacks • Awkward maintain state across events • Requires prior knowledge of the document • Maybe not so simple (lots to code)

Enter SimpleXML

SimpleXML • DOM-based processing - including xpath • Included in PHP5 • And, um, it’s simple

SimpleXML example

Example file

SimpleXML example

XPath example

SimpleXML + drupal_http_request() ftw

simple webservices

When SimpleXML isn’t simple


Example file

Namespaces example

maybe it’s not so bad

XML Writing

XML Writing example

Advantages for Drupal • Shorter, cleaner code (think cleaner aggregator.module, etc) • Manipulatable DOM structure (think hook_xml_alter) • XML Writing (think node_feed, etc)

Thanks, PHP5

Add a comment

Related pages

Drupal and SimpleXML | DrupalCon Barcelona 2007

One of the biggest advantages to the PHP 5 for Drupal 7 will be taking advantage PHP's Simple XML extension. SimpleXML is, as advertised, much simpler than ...
Read more

Drupal and SimpleXML | Drupal.org

... http://www.slideshare.net/walkah/2007-barcelona-drupalcon-drupal-and ... Drupal and SimpleXML. ... Drupal and PHP 5; Drupal and SimpleXML; Drupal as ...
Read more

Drupalcon Barcelona Presentations, Notes, and Videos ...

Drupalcon Barcelona was a huge success, ... Drupal and SimpleXML; Drupal as Web business ... presentations and sponsors for Drupalcon Barcelona 2007 ...
Read more

a reportback from DrupalCon Barcelona 2007 | Drupal Groups

Here are some reports from DrupalCon Barcelona! We had representatives of uk/nl, hungary, be, indybay & beirut imc present -- the conference as a whole had ...
Read more

Schedule | DrupalCon Barcelona 2007

DrupalCon Barcelona 2007. Accommodation; Schedule; Sponsors; FAQ; Discuss; About; Home. Schedule. ... Drupal and SimpleXML: walkah:
Read more

DrupalCon Barcelona: Best DrupalCon Ever! | GarfieldTech

DrupalCon Barcelona: Best DrupalCon Ever! ... (again!) talking about SimpleXML. ... Barcelona; Drupal; DrupalCon;
Read more

Simplexml | LinkedIn

View 235 Simplexml posts, presentations, experts, and more. Get the professional knowledge you need on LinkedIn. LinkedIn Home What is LinkedIn? Join Today
Read more

james walker - HubSlide

2007 Barcelona Drupalcon Image handling. 6 months ago. ... 2007 Barcelona Drupalcon: Drupal and SimpleXML. 6 months ago. Technology. Your Blog is Your ...
Read more