ElementTree and XPATH

Istvan Albert ialbert at mailblocks.com
Thu Dec 9 13:18:45 EST 2004


dayzman at hotmail.com wrote:

> it seems to be invalid syntax if I give "/a/b[0]" to the findall()
> method. Does anyone know the correct syntax?

I think the proper mindset going in should be that
elementtree does not support xpath but that
there are some handy constructs that resemble
the location steps of xpath.

Sometimes it takes very little work to achieve what
you want directly with python. In your case you could
probably use:

findall("/a/b")[0]

to the same effect.

Istvan.



More information about the Python-list mailing list