Wednesday, 12 October 2016

XML : I need to cut strings from a line(xml file) and save them in an array

i have another question regarding python. I need to save a specific string of a xml file(the string appears several times in the file) in a list.

  def parse_xml(self):      file_ = open("ErrorReactions_TestReport_20160831_165153.xml", "r")      for line in file_:          line.rstrip()          if "result_str" in line:              if line == "Skipped":                  "count how much test cases are skipped"              elif  line == "Failed"                  "count how much test cases failed              else:                  "count how much test cases passed"    

This is my code, my problem is that i need to save the string behind the parameter result_str and check if they match with "Skipped" or "Failed". How do i get that string saved in a variable? The lines look like this:

< verdict time="1472654306.7" result_str="Passed" result="2">Generator run successfully< /verdict> < verdict time="1472654306.7" result_str="Skipped" result="0" final="True">Testgenerator not active< /verdict>

No comments:

Post a Comment