How to find direct children of element in lxml

后端 未结 3 1289
情话喂你
情话喂你 2021-01-14 09:32

I found an object with specific class:

THREAD = TREE.find_class(\'thread\')[0]

Now I want to get all

elements that a

3条回答
  •  北海茫月
    2021-01-14 09:47

    You can try PARENT.getchildren()

    >>> root = etree.fromstring(xml)
    >>> root.xpath("//div[@class='thread']")[0].getchildren()
    [, ]
    

提交回复
热议问题