How to get the text from xml file using python?

Output.xml contains

<kw name="Given Launch the Browser" library="LandDef"> <kw name="Open the Browser" library="LandingPage"> <kw name="Open Browser" library="SeleniumLibrary"> <doc>Opens a new browser instance to the optional ``url``.</doc> <arguments> <arg>about:blank</arg> <arg>${BROWSER}</arg> </arguments> <msg timestamp="20200715 10:39:31.181" level="INFO">Opening browser 'headlesschrome' to base url 'about:blank'.</msg> <status status="PASS" starttime="20200715 10:39:31.181" endtime="20200715 10:39:33.740"></status> </kw> <kw name="APIResponse ping_msg" library="InsightsPageObject"> <kw name="Call Method" library="BuiltIn"> <doc>Calls the named method of the given object with the provided arguments.</doc> <arguments> <arg>${connectionObj}</arg> <arg>ping_msg</arg> </arguments> <assign> <var>${response_ping_msg}</var> </assign> <msg timestamp="20200715 10:39:33.742" level="INFO">${response_ping_msg} = o</msg> <status status="PASS" starttime="20200715 10:39:33.741" endtime="20200715 10:39:33.742"></status> 

I need to print this message from:- Opening browser ‘headlesschrome’ to base url ‘about:blank’.

 data_file = 'output.xml'  tree = ET.parse(data_file)  root = tree.getroot()  geoNode = root.find('msg').text  print(geoNode) 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.