Iterating multiple (parent,child) nodes using Python ElementTree
问题 The standard implementation of ElementTree for Python (2.6) does not provide pointers to parents from child nodes. Therefore, if parents are needed, it is suggested to loop over parents rather than children. Consider my xml is of the form: <Content> <Para>first</Para> <Table><Para>second</Para></Table> <Para>third</Para> </Content> The following finds all "Para" nodes without considering parents: (1) paras = [p for p in page.getiterator("Para")] This (adapted from effbot) stores the parent by