How to retrieve the parent node using cElementTree?

前端 未结 3 1734
鱼传尺愫
鱼传尺愫 2021-01-12 08:44

for the xml


  
     data1
  
  
     data2         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-12 09:02

    This syntax seemed to work for cElementTree

    ET.fromstring("").find('.//b/..')
    

    No going to base parent, and using double slash then single slash in path.
    (would have posted as a comment to above thread but it seems I have no privilege to)

提交回复
热议问题