tags:

views:

385

answers:

3

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.

+1  A: 

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.

Tony k
+1  A: 

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.

ADEpt
+2  A: 

Some possibly relevant packages:

Don Stewart