hit counter

Timeline

My development logbook

XPath, Python and Erlang

Just feel that python is easier for XML manipulation.

e.g.

1
2
3
4
from lxml import etree
f = open("digg-science-rss1.xml")
tree  = etree.parse(f)
tree.xpath(expr)

Very concise.

whereas in erlang, since the function xmerl:string may return a list that’s composed of various record type (such as xmlRecord or xmlText etc), it makes the handling more complex (one clause per record type). The printout from REPL is also a lot more verbose. e.g.

1
2
3
4
5
6
7
8
9
10
11
...
      #xmlText{
          parents = [{item,16},{channel,2},{rss,1}],
          pos = 3,language = [],value = "\n   ",type = text},
      #xmlElement{
          name = link,expanded_name = link,nsinfo = [],
          namespace = 
              #xmlNamespace{
                  default = [],
                  nodes =
...