How can I access namespaced XML elements using BeautifulSoup?

后端 未结 3 954
清酒与你
清酒与你 2020-12-07 01:30

I have an XML document which reads like this:



4000
0
<         


        
3条回答
  •  不思量自难忘°
    2020-12-07 01:56

    This is an old question but somebody might not know that at least BeautifulSoup 4 does handle namespaces well if you pass 'xml' as second argument to the constructor:

    soup = BeautifulSoup("""
    
    4000
    0
    
    """, 'xml')
    
    print soup.prettify()
    
    
     
      
       4000
      
      
       0
      
     
    
    

提交回复
热议问题