Can someone help here, I want to parse a XML file which asks for authentication(user, password) but with my code. Can someone help what should I use or edit in my code so that my code can parse svn https link?
import urllib.request as url
import xml.etree.ElementTree as ET
xmlfile=url.urlopen(r'file:///D:/Python/user.html')
def fileparse(xmlfile):
tree=ET.parse(xmlfile)
root=tree.getroot()
#print(root.tag)
users={root.get("name"):[]}
for item in root.findall("client"):
users[root.get("name")].append(item.get("name"))
return users
k1=input("user or client, please mention:")
if k1=='user':
k10=input("Enter the user id you want to search for:")
d1=fileparse(xmlfile)
for k,v in d1.items():
if k==k10:
print(k,v)
elif k1=='client':
c10=input("Enter the client name you want to search for:")
d1=fileparse(xmlfile)
for k,v in d1.items():
if c10 in v:
print(k)
else:
print("sorry please check your input values")
我认为你的代码中有缩进错误
用户和for循环应该存在于要执行的函数中
相关问题 更多 >
编程相关推荐