How can I do the following in python: given two strings: form=""" <html> <head> <title> My Sample Web Page </title> </head> <body bgcolor="white"> <p> What are the weekdays? <ol> <li>Monday</li> <li>Tuesday</li> <li>Wednesday</li> <li>Thursday</li> <li>Friday</li> </ol> </p> </body> </html> """ fillin=""" <dutchdays> <Monday>maandag</Monday> <Tuesday>dinsdag</Tuesday> <Wednesday>woensdag</Wednesday> <Thursday>donderdag</Thursday> <Friday>vrijdag</Friday> <Saturday>zaterdag</Saturday> <Sunday>zondag</Sunday> </dutchdays> """
How can I compare the text in the element tags <li> with the elements tags in filling and if they match replace the text within the elements tags <li> with the text in the matching element tag of fillin. For example Since the text Monday in form matches the Element tag <Monday> in fillin put maandag in the element tag <li> of Monday. Kind of a Pseudo Code import xml.dom.minidom def xmlform(form=None, fillin=None): Fo = xml.dom.minidom.parseString(form) Fi = xml.dom.minidom.parseString(fillin) Fo information: get element tags for li get text for li Fi information: get childtags for dutchdays if(text for li=child tags for dutchdays): replace child tags for dutchdays text with text for li There needs to be a loop but I cannot figure out what type of loop maybe a while len(Fo)>0: to process through the form. Thanks for the help!! -- http://mail.python.org/mailman/listinfo/python-list