Hi Everyone, So i have been trying to figure this out for ages. Im just not able to to get the algorithm straight.
Say I am given a string containing markup tags ex. <html> </html> in a string like this:
<head> <title> Example </title> </head>
<body> quiet <CAPSLOCK> LOUD </CAPSLOCK> quiet </body>
I am trying to get python to return a list of nested lists embedding each tag and the contents inbetween it in a new nested list. so for the example above it would be
[['<html>', ['<head>', ['<title>', 'Example', '</title>'], '</head>'], ['<body>', 'quiet', ['<CAPSLOCK>', 'LOUD', '</CAPSLOCK>'], 'quiet', '</body>'], '</html>']] .
I know i have to use string.split to seperate my string by whitespaces. but have no idea where to go from there. I am a python newbie. Any help would be greatly appreciated!
Thanks in advanced