BeautifulSoup raise AttributeError when xml tag name contains capital letters

前端 未结 2 872
再見小時候
再見小時候 2021-01-24 03:58

I\'m trying to get all the XML attributes for the tag Name.

Getting this error:

AttributeError: \'NoneType\' object has no attribute \'attr         


        
2条回答
  •  情话喂你
    2021-01-24 04:38

    In BeautifulSoup 4, you can use

    doc = bs.BeautifulSoup(xml, "xml")
    div = doc.find("Name")
    

    This should work.

提交回复
热议问题