1.タグ「sanity_results」の間のxmlファイルを読み取ろうとしています(入力http://pastebin.com/p9H8GQt4を見てください)出力を印刷します
2. http:// または // を含む行または行の一部について、「a href」ハイパーリンク タグをリンクに追加して、電子メールに投稿したときに電子メールにハイパーリンクとして表示されるようにします。
Input file(results.xml)
http://pastebin.com/p9H8GQt4
def getsanityresults(xmlfile):
srstart=xmlfile.find('<Sanity_Results>')
srend=xmlfile.find('</Sanity_Results>')
sanity_results=xmlfile[srstart+16:srend].strip()
sanity_results = sanity_results.replace('\n','<br>\n')
return sanity_results
def main ():
xmlfile = open('results.xml','r')
contents = xmlfile.read()
testresults=getsanityresults(contents)
print testresults
for line in testresults:
line = line.strip()
//How to find if the line contains "http" or "\\" or "//" and append "a href"attribute
resultslis.append(link)
if name == ' main ': main()