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

2024-09-22 16:28:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我只是想得到一个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>

这是访问值的代码:

from lxml import etree
doc = etree.parse ( 'clasif.xml' )
root = doc.getroot()
elem= doc.xpath ('//estacion')

我做错什么了?你知道吗


Tags: 文件docversionxmletreeclasifestaciontratamiento