Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery like selector in Haskell

Tags:

jquery

haskell

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.

like image 386
Surya Avatar asked Apr 18 '09 20:04

Surya


4 Answers

Some possibly relevant packages:

  • DOM for Haskell
  • HaXML
  • XML tools for Haskell
like image 71
Don Stewart Avatar answered Nov 03 '22 14:11

Don Stewart


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.

like image 23
Anthony Avatar answered Nov 03 '22 15:11

Anthony


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.

like image 1
ADEpt Avatar answered Nov 03 '22 14:11

ADEpt


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.

like image 1
Hiro Avatar answered Nov 03 '22 15:11

Hiro