Python Forum
Parse XML - how to handle deep levels/hierarchy
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parse XML - how to handle deep levels/hierarchy
#4
Not upset, it's just forum rules to not start new threads on same subject,
see: https://python-forum.io/misc.php?action=help&hid=22
Quote:and it only produced the root level and the level below
which I explained in the text.
I probably didn't explain that I would continue with what I started. Stranac's method is probably what you want to use. once you have the child nodes, you can look at the attrib values which should be dictionaries. You can also get the length of each child with len(child), which if greater than one, indicates that each attrib can be accessed as child[0].attrib and child[1].attrib.

From there, you can get the values in an attrib with:
for key, value in child.attrib.items():
    ...
Hope that helps
Reply


Messages In This Thread
RE: Parse XML - how to handle deep levels/hierarchy - by Larz60+ - Apr-16-2018, 03:48 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  deep learning python Stevedas 1 1,734 Sep-26-2021, 08:32 AM
Last Post: Yoriz
  How can i generate hierarchy directory Anldra12 2 2,003 Jun-05-2021, 08:28 AM
Last Post: Anldra12
  [split] Teacher (thrown in at the deep end - help) Mr90 2 3,056 May-23-2018, 02:04 PM
Last Post: DeaD_EyE
  Teacher (thrown in at the deep end - help) Mr90 5 3,982 May-22-2018, 01:08 PM
Last Post: DeaD_EyE
  Relative import multiple levels ? Windspar 3 4,492 Feb-02-2018, 11:55 PM
Last Post: Windspar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020