具体文档参见:http://docs.python.org/library/xml.etree.elementtree.html

例子:

#-*-coding:utf-8-*-
from xml.etree import ElementTree as ET

file = ET.parse('ftp.xml')
ftps = file.findall('/ftp')
for ftp in ftps:
    print ftp.attrib
    print ftp.get('name')
    print ftp.get('ip')
    print ftp.get('username')

 

 

ftp.xml 文件:
<?
xml version = "1.0" encoding= "UTF-8"?> <TotalFTP> <ftp name='ftpUbuntu' ip='192.168.88.245' port ='21' username = 'hzhida' password = 'dingjia'/> <ftp name='windowftp' ip='192.168.88.162' port = '21' username = 'hzhida' pasword = 'dingjia'/> </TotalFTP>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
猜你喜欢
  • 2021-08-17
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案