0

我正在尝试根据绝对路径从 xml 树中查找所有直接子元素

由于机密,我无法附加 xml

full_entry_point=".//Home/sub/Entry/accessory/Entry"

default_entry=".//Home/sub/Entry"

我有下面的for循环,我在其中尝试遍历'default_entry',一旦我获取标签,我需要根据条件将迭代切换到循环中的full_entry_point

status = False
for entry in tree.findall(default_entry.lower()):
   path="somepath"
  find_result = entry.find(path).text()
  if status== True:
      """
      Here i need to change the iteration value of 'entry' from 'default_entry' to 'full_entry_point'
      like 
      entry should point to 'tree.findall(full_entry_point.lower())'
      that mean it should fetch direct child element of 'full_entry_point'
      """

请让我知道如何实现相同的?

谢谢

4

0 回答 0