私は約2時間掘りと掘りしてきたが、私はこのエラーの原因を見つけることができませんでした:lxmlのElement.getAttribute()メソッド呼び出しはどこに行きましたか?
1) JBoss
2) Tomcat
Select an application: 1
<App id="1" type="JBoss" path="" state="ok"/>
Traceback (most recent call last):
File "/root/RService.py", line 47, in <module>
Stats = app.getAttribute('state')
AttributeError: 'lxml.etree._Element' object has no attribute 'getAttribute'
そして、私のコードの一部は次のとおりです。
app_types = set(nXML.xpath('//Group[@id=$gList]//descendant::App/@type',gList=gList))
app_dict = dict((x+1,y) for (x,y) in enumerate(app_types))
print "\n".join("%d) %s" % x for x in sorted(app_dict.items()))
app_selection = input("Select an application: ")
app_type = app_dict.get(int(app_selection))
for app in nXML.xpath('//Group[@id=$gList]//App[@type=$app_type]',gList=gList,app_type=app_type):
print etree.tostring(app)
Stats = app.getAttribute('state')
stype = app.getAttribute('type')
trigger = 0
while trigger < 1:
if Stats == 'ok':
try: ... ...
それは働いていました以前は、構文はどうなりましたか?
ありがとうございました
現在のドキュメントには、このメソッドの記述はありません。あなたは古代のバージョンからアップグレードしましたか? – delnan