Keep the fluent flow: From time to time you find exceptional libraries out there. This posting is about one I got pointed with the finger on while being on a PHP unconf last year and I must admit that I didn’t took the chance to play with it until last week. It’s a hell of a library you better get to know: FluentDOM.

If you work with XML or HTML (and who does not these days?) you will love it. The developer(s) were influenced by jQuery on how to functionally access the DOM with it’s fluent interfaces. Now you can do so (xpath queries not css selector based) inside PHP as well. It’s not that well documented online, but I got it to work in my Eclipse PDT pretty well and since it provides auto-complete and the usual hints it was fun to work with.

Example things I did so far: A RSS feed parser, a website scraper (use of a site as a datasource), a website redesign (generation of HTML files based on XML data) and I used it as a component in my statistical script I did to get the number of open bugs in the wordpress project over time.

One little problem I ran over was that loading strings as text/html are assumed as being latin-1 encoded. So they get converted to utf-8 – even if they aren’t. For me that was no real problem, I just changed the encoding to latin-1 (utf8_decode) prior to loading the data.

This entry was posted in Hakre's Tips, Tools and tagged , , , , , . Bookmark the permalink.

6 Responses to FluentDOM

  1. Pingback: FluentDOM Usage: The id() Problem « hakre on wordpress

  2. Pingback: Line Endings in diverse Operating Systems | hakre on wordpress

  3. scribu says:

    You should also take a look at phpQuery:


    • hakre says:

      Sure, that’s one lib you should at least try out as well and to know about.

      I must admit that for me the FluentDOM approach is much more effective with multiple stuff I already practically did. What I like most is to switch between FluentDOM and DOMDocument back and forth and the superb features FluentDOM offers for extensibility.

      I might show some stuff with phpQuery as well, I used it, before I switched over to FluentDOM. There is some HTTP-Client shipping with phpQuery. Maybe I find some old sample code, I was ready to scrape what I wanted within minutes with phpQuery not knowing the project before.

  4. Pingback: QueryPath – Find your Way | hakre on wordpress

  5. Pingback: FluentDOM now on Github | hakre on wordpress

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.