How to make this kind of record pattern matching in Elixir?
[ #xmlText{value=Rank} ] = xmerl_xpath:string("//SalesRank/text()", Xml),
Bonus: rewrite this example from Dave Thomas's blog in Elixir.
Update:
found what was my problem. You have to use
defrecord :xmlText, Record.extract(:xmlText, from_lib: 'xmerl/include/xmerl.hrl')
to extract the record from XMerL lib into your program as stated here. Then the .value
syntax works and the line can be written as follows:
rank = Enum.first(xmerl_xpath.string('//SalesRank/text()', xml)).value