#phpbcat




FluentDOM
 Thomas Weinert
About Me

●   Application Developer
    ●   PHP
    ●   JavaScript
    ●   XSL
●   Papaya Software GmbH
    ●   papaya CMS...
About You?
About FluentDOM

●   JQuery API
●   DOMNodeList replacement
●   Learning Project
    ●   Test driven development
    ●   C...
Differences To jQuery

●   „Only“ Traversing, Manipulation and some Core
    functions
●   Xpath Expressions (not CSS Sele...
Chaining

●   Methods return objects
Chaining Sample


$fd = FluentDOM($html, 'html')
  ->find('/html/head/title')
  ->add('//h1')
  ->add('//h2');
Traversing

●   find()      ●   children()       ●   first()
●   add()       ●   closest()        ●   last()
●   not()    ...
Xpath

●   XML Path Language
●   W3C Recommendation 16 November 1999
●   Used by
    ●   XSLT 1
    ●   Xpointer
●   More ...
Namespaces

●   Xpath depends on namespaces
●   Register your own namespaces prefixes
●   Method: namespaces()

$title = F...
Interfaces

●   IteratorAggregate
    ●   Iterator
    ●   RecursiveIterator
    ●   Seekable
●   Countable
●   ArrayAcces...
Functions

●   Create FluentDOM object and load data
    ●   FluentDOM
    ●   FluentDOMStyle
Manipulation

●   append()        ●   appendTo()      ●   xml()
●   prepend()       ●   prependTo()     ●   text()
●   bef...
Loaders

●   Default Loaders
    ●   DOMDocument, DOMNode
    ●   XML (file and string)
    ●   HTML (file and string)
●  ...
Own Loaders

●   Interface FluentDOMLoader
    ●   load() returns DOMDocument or DOMNode
Extending FluentDOM

●   FluentDOMCore
    ●   spawn()
    ●   push()
    ●   unique()
    ●   _applyContentsToNodes()
Future

●   CSS Selectors
●   ?
Get It

●   http://fluentdom.org
●   http://nightly.fluentdom.org
●   svn://svn.fluentdom.org
Upcoming SlideShare
Loading in …5
×

FluentDom

1,459 views
1,371 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,459
On SlideShare
0
From Embeds
0
Number of Embeds
143
Actions
Shares
0
Downloads
1
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

FluentDom

  1. 1. #phpbcat FluentDOM Thomas Weinert
  2. 2. About Me ● Application Developer ● PHP ● JavaScript ● XSL ● Papaya Software GmbH ● papaya CMS ● Technical Director
  3. 3. About You?
  4. 4. About FluentDOM ● JQuery API ● DOMNodeList replacement ● Learning Project ● Test driven development ● Continous Integration ● Parser ● Tobias Schlitt ● Bastian Feder, Thomas Weinert
  5. 5. Differences To jQuery ● „Only“ Traversing, Manipulation and some Core functions ● Xpath Expressions (not CSS Selectors) ● No method html() but xml() ● Callbacks have a $node parameter
  6. 6. Chaining ● Methods return objects
  7. 7. Chaining Sample $fd = FluentDOM($html, 'html') ->find('/html/head/title') ->add('//h1') ->add('//h2');
  8. 8. Traversing ● find() ● children() ● first() ● add() ● closest() ● last() ● not() ● contents() ● prev() ● filter() ● parent() ● prevAll() ● has() ● parents() ● prevUntil() ● end() ● parentsUntil() ● next() ● andSelf() ● siblings() ● nextAll() ● nextUntil()
  9. 9. Xpath ● XML Path Language ● W3C Recommendation 16 November 1999 ● Used by ● XSLT 1 ● Xpointer ● More specific then CSS ● More powerful then CSS
  10. 10. Namespaces ● Xpath depends on namespaces ● Register your own namespaces prefixes ● Method: namespaces() $title = FluentDOM($xml) ->namespaces( array('project-atom' => 'http://www.w3.org/2005/Atom') ) ->evaluate( 'string(/project-atom:feed/project-atom:title)' );
  11. 11. Interfaces ● IteratorAggregate ● Iterator ● RecursiveIterator ● Seekable ● Countable ● ArrayAccess (read only)
  12. 12. Functions ● Create FluentDOM object and load data ● FluentDOM ● FluentDOMStyle
  13. 13. Manipulation ● append() ● appendTo() ● xml() ● prepend() ● prependTo() ● text() ● before() ● insertAfter() ● attr() ● after() ● insertBefore() ● addClass() ● remove() ● wrap() ● removeClass() ● replaceAll() ● wrapAll() ● toggleClass() ● replaceWith() ● wrapInner()
  14. 14. Loaders ● Default Loaders ● DOMDocument, DOMNode ● XML (file and string) ● HTML (file and string) ● Additional Loaders ● SimpleXMLElement ● PDO ● JSON
  15. 15. Own Loaders ● Interface FluentDOMLoader ● load() returns DOMDocument or DOMNode
  16. 16. Extending FluentDOM ● FluentDOMCore ● spawn() ● push() ● unique() ● _applyContentsToNodes()
  17. 17. Future ● CSS Selectors ● ?
  18. 18. Get It ● http://fluentdom.org ● http://nightly.fluentdom.org ● svn://svn.fluentdom.org

×