Quantcast
Viewing all articles
Browse latest Browse all 21

FluentDOM

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.

Image may be NSFW.
Clik here to view.

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.


Tagged: FluentDOM, HTML, PHP, phpQuery, XML, XPath Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 21

Trending Articles