FluentDom
Click here to load reader
-
Upload
thomas-weinert -
Category
Documents
-
view
1.217 -
download
0
Transcript of FluentDom
![Page 1: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/1.jpg)
#phpbcat
FluentDOMThomas Weinert
![Page 2: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/2.jpg)
About Me
● Application Developer● PHP● JavaScript● XSL
● Papaya Software GmbH● papaya CMS● Technical Director
![Page 3: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/3.jpg)
About You?
![Page 4: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/4.jpg)
About FluentDOM
● JQuery API● DOMNodeList replacement● Learning Project
● Test driven development● Continous Integration● Parser
● Tobias Schlitt● Bastian Feder, Thomas Weinert
![Page 5: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/5.jpg)
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
![Page 6: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/6.jpg)
Chaining
● Methods return objects
![Page 7: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/7.jpg)
Chaining Sample
$fd = FluentDOM($html, 'html') ->find('/html/head/title') ->add('//h1') ->add('//h2');
![Page 8: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/8.jpg)
Traversing
● find()● add()● not()● filter()● has()● end()● andSelf()
● children()● closest()● contents()● parent()● parents()● parentsUntil()● siblings()
● first()● last()● prev()● prevAll()● prevUntil()● next()● nextAll()● nextUntil()
![Page 9: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/9.jpg)
Xpath
● XML Path Language● W3C Recommendation 16 November 1999● Used by
● XSLT 1● Xpointer
● More specific then CSS● More powerful then CSS
![Page 10: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/10.jpg)
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)' );
![Page 11: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/11.jpg)
Interfaces
● IteratorAggregate● Iterator● RecursiveIterator● Seekable
● Countable● ArrayAccess (read only)
![Page 12: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/12.jpg)
Functions
● Create FluentDOM object and load data● FluentDOM● FluentDOMStyle
![Page 13: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/13.jpg)
Manipulation
● append()● prepend()● before()● after()● remove()● replaceAll()● replaceWith()
● appendTo()● prependTo()● insertAfter()● insertBefore()● wrap()● wrapAll()● wrapInner()
● xml()● text()● attr()● addClass()● removeClass()● toggleClass()
![Page 14: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/14.jpg)
Loaders
● Default Loaders● DOMDocument, DOMNode● XML (file and string)● HTML (file and string)
● Additional Loaders● SimpleXMLElement● PDO● JSON
![Page 15: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/15.jpg)
Own Loaders
● Interface FluentDOMLoader● load() returns DOMDocument or DOMNode
![Page 16: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/16.jpg)
Extending FluentDOM
● FluentDOMCore● spawn()● push()● unique()● _applyContentsToNodes()
![Page 17: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/17.jpg)
Future
● CSS Selectors● ?
![Page 18: FluentDom](https://reader037.fdocuments.us/reader037/viewer/2022100602/558154aed8b42ab9548b50de/html5/thumbnails/18.jpg)
Get It
● http://fluentdom.org● http://nightly.fluentdom.org● svn://svn.fluentdom.org