Parsing The Xml File To Create Hyperlinks
1.I am trying to read an xml file between the tags 'sanity_results'( look at for the input http://pastebin.com/p9H8GQt4) and print the output 2.for any line or part of line that h
Solution 1:
Have a look at your error message:
AttributeError: 'file'object has no attribute 'find'
And then have a look at main()
: you're feeding the result of open('results.xml', 'r')
into getsanityresults
. But open(...)
returns a file object, whereas getsanityresults
expects xmlfile
to be a string.
You need to extract the contents of xmlfile
and feed that inti getsanityresults
.
To get the contents of a file, read [this bit of the python documentation]9http://docs.python.org/2/tutorial/inputoutput.html#methods-of-file-objects).
In particular, try:
xmlfile = open('results.xml', 'r')
contents = xmlfile.read() # <-- this is a stringtestresults = getsanityresults(contents) # <-- feed a string into getsanityresults# ... rest of code
Post a Comment for "Parsing The Xml File To Create Hyperlinks"