12
Ben BeautifulStoneSoup
ile bir XML dosyası düzenler bir senaryo yazıyorum ama kütüphane tüm etiketler harfe dönüştürür. Davayı korumak için bir seçenek var mı?Nasıl BeautifulSoup.BeautifulStoneSoup içinde harfe duyarlı etiketlerin bakımını?
import BeautifulSoup
xml = "<TestTag>a string</TestTag>"
soup = BeautifulSoup.BeautifulStoneSoup(xml, markupMassage=False)
print soup.prettify() # or soup.renderContents()
#prints
>>> <testtag>a string</testtag>
#instead of the expected
>>> <TestTag>a string</TestTag>
sayesinde yükseltme yaptı ve o inşaat büyük. Gelecekteki okuyucular için: vadede '' o 'xml' kütüphane, hiçbir şartname ile çalıştırırsanız BeautifulSoup tavsiye ettiğinin değil' lxml' gerektirdiği belirtilmelidir değer – TankorSmash
--upgrade' BeautifulSoup yüklemek pip değil BeautifulSoup4' yüklemek pip. 'lxml' davasını korumaz. –
@KeithSmiley: 'çorba kullanırken Evet = BeautifulSoup (xml, "Lxml")', LXML HTML ayrıştırıcı kullanılır. Http://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser adresine bakın. – mzjn