4 ms·
I love Haskell, but parsing XML with it is a huge pain. Someday I want to write a better XML parsing library, but for now I use HXT. I wrote a blog post a while
by egonschiele 15y ago
I love Haskell, but parsing XML with it is a huge pain. Someday I want to write a better XML parsing library, but for now I use HXT. I wrote a blog post a while back that shows some sample usage: http://adit.io/posts/2012-03-10-building_a_concurrent_web_scraper_with_haskell.html http://adit.io/posts/2012-03-10-building_a_concurrent_web_sc....
- ericssmith 15y agoI use hexpat and it works nicely. I wasn't able to get very far with either haxml or hxt before having grief.
- reddit_clone 15y agoDoes hexpat work on Windows? I am asking since it is linking to expat dynamic library..
- egonschiele 15y agoI use HXT to parse HTML. AFAICT, Hexpat doesn't do much besides parse the XML file into a tree. It doesn't have the niceties that Nokogiri or BeautifulSoup do. For example, I can use Nokogiri to get all the links on a page like so: page.css("a"). HXT allows me to come close to this: tree >>> getXPathTreesInDoc "//a" But I haven't seen a single Haskell XML parsing library that is as nice as Nokogiri.
- ericssmith 15y agoIn my work, I read in XML, parse its elements, attributes, and data, producing new XML. Along with Parsec, Hexpat is well-suited to the task. I haven't had to parse HTML in Haskell. I use BeautifulSoup for that. I wouldn't be surprised if the Haskell libraries aren't as useful for that kind of thing.
- egonschiele 15y agoI wrote up a guide to working with HTML in HXT: http://adit.io/posts/2012-04-14-working_with_HTML_in_haskell.html http://adit.io/posts/2012-04-14-working_with_HTML_in_haskell... You might find it handy if you decide to give HXT another go :)
- reddit_clone 15y agoThe article was a linkbait which rehashes tired old arguments. But I do agree on the XML. It is just too hard for beginners to grok how to process XML in haskell.