[erlang-questions] Rant: I hate parsing XML with Erlang

Joel Reymont joelr1@REDACTED
Tue Oct 23 14:36:24 CEST 2007


Kenneth,

On Oct 23, 2007, at 12:57 PM, Kenneth Lundin wrote:

> But I don't think you can draw any conclusions regarding Erlang as a
> language and how well suited it is for XML programming because of  
> this.

Take a look at the following [1] and try to visualize an  
implementation in Erlang. More thoughts after the example.

The data:

<Export>
   <Product>
     <SKU>403276</SKU>
     <ItemName>Trivet</ItemName>
     <CollectionNo>0</CollectionNo>
     <Pages>0</Pages>
   </Product>
</Export>

The Ruby hPricot code:

FIELDS = %w[SKU ItemName CollectionNo Pages]

doc = Hpricot.parse(File.read("my.xml"))
(doc/:product).each do |xml_product|
   product = Product.new
   for field in FIELDS
     product[field] = (xml_product/field.intern).first.innerHTML
   end
   product.save
end

This dovetails with the metaprogramming EPP that Vlad has just  
submitted. Erlang is mind-numbingly rigid in its syntax. I cannot  
emphasize this more!!!

The simplest example is that the "synchronous message passing"  
notation of !! (double exclamation point). It could be used to neatly  
translate the above into XmlProduct !! {search, Field !! intern} !!  
first !! innerHTML. Alas, this is impossible even with a parse  
transform since there's no !! in Erlang.

Any suggestions to using call(...) instead of !! will only prove my  
point about the ugly user interface.

Why does it upset me so much you may ask? It's very simple! Erlang as  
a huge unstoppable HTML and XML transformation engine. Throw together  
a bunch of boxes and you can start sucking in web pages and spitting  
out RSS feeds, rivers of news, etc.

Erlang enables mashups on a large scale but this type of application  
needs a friendly user interface, one that seems to be impossible to  
build right now due to syntax limitations!

	Thanks, Joel

[1] http://errtheblog.com/post/8

--
http://wagerlabs.com




More information about the erlang-questions mailing list