2007 Barcelona Drupalcon: Drupal and SimpleXML

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    3 Favorites

    2007 Barcelona Drupalcon: Drupal and SimpleXML - Presentation Transcript

    1. Drupal and SimpleXML
    2. XML parsing • Very well defined, well known standards • Excellent support ... • ... in most other languages • Long-standing PHP weakness (up to version 4)
    3. two main models
    4. SAX
    5. Simple API for XML • Stream - based xml parsing • Event - driven API • Uni-directional
    6. DOM
    7. Document Object Model • Full object representation of an XML document • Supports writing documents • Same system used by browsers, javascript, etc (i.e. “known quantity”)
    8. 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
    9. 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
    10. 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
    11. SAX example
    12. SAX example (cont.)
    13. SAX example (cont)
    14. SAX example (cont)
    15. SAX drawbacks • Awkward maintain state across events • Requires prior knowledge of the document • Maybe not so simple (lots to code)
    16. Enter SimpleXML
    17. SimpleXML • DOM-based processing - including xpath • Included in PHP5 • And, um, it’s simple
    18. SimpleXML example
    19. Example file
    20. SimpleXML example
    21. XPath example
    22. SimpleXML + drupal_http_request() ftw
    23. simple webservices
    24. When SimpleXML isn’t simple
    25. namespaces
    26. Example file
    27. Namespaces example
    28. maybe it’s not so bad
    29. XML Writing
    30. XML Writing example
    31. Advantages for Drupal • Shorter, cleaner code (think cleaner aggregator.module, etc) • Manipulatable DOM structure (think hook_xml_alter) • XML Writing (think node_feed, etc)
    32. Thanks, PHP5

    + James WalkerJames Walker, 3 years ago

    custom

    4866 views, 3 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 4866
      • 4866 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 3
    • Downloads 123
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories