I am doing some server side html processing in Haskell. Wondering if there is an equivalent of jquery type selector engine implemetation for haskell out there that i could use. Google doesnt yield anything.
Some possibly relevant packages:
The way jQuery's selector engine (roughly) works is by utilizing existing Javascript DOM-selection/manipulation code. No one has created something like this in Haskell to my knowledge, and probably with good reason. It's easy to do with Javascript because of the DOM and existing functionality, but in Haskell, you have neither a big need for it nor is it particularly easy.
As far as writing it yourself, however, you'll just be doing a lot of nasty XML parsing. If you can tidy up the page into XHTML, you can parse it as XML; then, you can select based on if a node has children, if a node has a given attribute, what the element itself is, and so on.
Maybe you're just looking for an XML library then! If this works for you, I'd recommend HaXml. I've only used it twice yet, but I've liked it. Nothing quite like this application, however.
Take a look at the Xtract module from the HaXml. There is a command-line tool of the same name there to test it out.
I made a dom-selector package that supports some css selectors. This works on xml-conduit and html-conduit packages. I expect xml-conduit and html-conduit will be actively developed, since they accompany Yesod, a major web server framework for Haskell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With