I have a text files in a one directory like "Rest.txt", "Test.txt". Sample string in a txt file as shown below.
Input:
<Hello> <Message><stdout>"weblogic.servelt.Default(self-tuning)"] <12-18-2020> <?xml version="1.0" encoding="UTF-8"?><breakfast_menu><food><name>Belgian Waffles</name><price>$5.95</price> <description>Two of our famous Belgian Waffles with plenty of real maple syrup</description><calories>650</calories></food><food><name>Strawberry Belgian Waffles</name> <price>$7.95</price><hello><sjiadasjhds>954jkldfksfkfjsdfklsdjf
In between the above given string there has XML tags. I need to extract all XML tags and save it in another directory using python. Like this I need to extract all XML data in all text files and save it.
Output :
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>Two of our famous Belgian Waffles with plenty of real maple syrup</description><calories>650</calories>
</food>
</breakfast_menu>```