从我的转换XML标记为小写preventing BeautifulSoup [英] Preventing BeautifulSoup from converting my XML tags to lowercase
问题描述
我使用BeautifulStoneSoup解析XML文档并改变某些属性。我注意到,所有的XML标签自动转换为小写字母。例如,我的源文件的< DocData>
元素,BeautifulSoup转换成< docdata>
。这似乎是造成因为我喂我修改的XML文档似乎不接受小写版本的程序问题。有没有一种方法,以prevent这种行为在BeautifulSoup?
I am using BeautifulStoneSoup to parse an XML document and change some attributes. I noticed that it automatically converts all XML tags to lowercase. For example, my source file has <DocData>
elements, which BeautifulSoup converts to <docdata>
. This appears to be causing problems since the program I am feeding my modified XML document to does not seem to accept the lowercase versions. Is there a way to prevent this behavior in BeautifulSoup?
推荐答案
没有,这不是一个内置选项。源是pretty简单,虽然。它看起来像你想改变标签EN codedName的价值。 __ __海峡
No, that's not a built-in option. The source is pretty straightforward, though. It looks like you want to change the value of encodedName in Tag.__str__.
这篇关于从我的转换XML标记为小写preventing BeautifulSoup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!