尝试在python中使用lxml获取xml文件的一些值

尝试在python中使用lxml获取xml文件的一些值,python,xpath,lxml,Python,Xpath,Lxml,我只是想得到XML文件的一些值,但什么也得不到 <?xml version="1.0" ?> <clasif> <estacion>Estacion</estacion> <ncamaras>1</ncamaras> <fph>1</fph> <tratamiento>3</tratamiento> <finicio>17/07/2011<

我只是想得到XML文件的一些值,但什么也得不到

<?xml version="1.0" ?>
<clasif>
  <estacion>Estacion</estacion>
  <ncamaras>1</ncamaras>
  <fph>1</fph>
  <tratamiento>3</tratamiento>
  <finicio>17/07/2011</finicio>
  <ffin>17/07/2011</ffin>
  <hinicio>04</hinicio>
  <hfin>06</hfin>
</clasif>

我做错了什么?

您的实际XML是否声明了命名空间(
xmlns=“…”
)?
print elem[0]。text
return
Estacion
对我来说,您期望什么?您说“什么都得不到”。什么特别告诉你你什么也得不到?可能是
elem
实际上保存了正确的结果(节点集),但没有正确使用
elem
的值。给我们看看你的代码。
len(elem)
elem[0]做什么。标记
返回?谢谢Dikei,这对我来说是完美的工作。我现在正在学习Python!