shitnersefe
New Member
I have two similar XML strings like this:str1:\[code\]<result> <q> <somestuff>xxx</somestuff> </q><items> <res> <first>xxx1</first> <second>xxx1</second> </res> <res> <first>xxx2</first> <second>xxx2</second> </res> <res> <first>zzz</first> <second>zzz</second> </res> (etc.)</items></result>\[/code\]str2:\[code\]<result> <q> <somestuff>yyy</somestuff> </q><items> <res> <first>yyy1</first> <second>yyy1</second> </res> <res> <first>yyy2</first> <second>yyy2</second> </res> <res> <first>zzz</first> <second>zzz</second> </res> (etc.)</items></result>\[/code\]What would be the easiest way to merge those two strings with xml.dom.minidom in python 2 to get a final XML string like this:\[code\]<result> <q> <somestuff>xxx yyy</somestuff> </q><items> <res> <first>xxx1</first> <second>xxx1</second> </res> <res> <first>xxx2/first> <second>xxx2</second> </res> <res> <first>yyy1</first> <second>yyy1</second> </res> <res> <first>yyy2</first> <second>yyy2</second> </res> <res> <first>zzz</first> <second>zzz</second> </res> (etc.)</items></result>\[/code\]Note that both strings can have same values, so in situations like that they shouldn't be duplicated in final result.