0

We have requirement to write simple xml in string format from listed dictionaries
iterating through list and iterating through each dictionarie and write xml format (i.e. dict key is xml key and dict value is dict value ex:- <First_name>James</First_name> ), if the value contains dictionary again we need to loop on that value and write innter xml format string, and again if the inner value is dictionary and again a loop to write xml string...

So we may not know how many inner dictionaries comes but we need to write nested loop how that possible in python?

Edited by kuchi: spell correction

4
Contributors
4
Replies
6
Views
5 Years
Discussion Span
Last Post by pyTony
0

Thanks a lot dude :) i am new to Python, concepts are same, syntax is little bit different only

0

Use recursion: write a function F(dictionary) to write a dictionary. In the function's body, iterate over the dictionary items, and if one of the item contains a new dictionary, call F(subdictionary) again to write this dict.

0

Thanks Gribouillis, I've question that can we call a function itself which is already in progress? I thought the same but didn't try.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.