python xml structure iteration not keeping variables within for loops -
i'm using next code iterate through xml file, want extract folder structure. ideally i'd list in each element have next structure: top_folder, first_folder, page_view alternatively dictionary top_folder , page_view work me. problem i'm having if seek print variable previous loop, doesn't work. don't understand, i'm utilize in other parts of script. code is:
top = "" first_iter in root_navigation: second_iter in first_iter: top_folder in second_iter: if top_folder.text , top_folder.text.strip(): #print top_folder.text top == top_folder.text first_folder in top_folder: if first_folder.text , first_folder.text.strip(): #print " "+first_folder.text first = first_folder.text page_view in first_folder: if page_view.text , page_view.text.strip(): #print " "+page_view.text print top+":"+first+":"+page_view.text so far i've tried above code, , straight printing top_folder.text , first_folder.text in lastly if.
the output manage get, commented prints like: top folder first folder page view first folder page view .....
which doesn't work i'd have list or match later view name , top folder it.
any ideas of why variables not getting across loops or way this?
thanks in advance :-)
python xml
No comments:
Post a Comment