本文整理汇总了Python中XML.xml_read方法的典型用法代码示例。如果您正苦于以下问题:Python XML.xml_read方法的具体用法?Python XML.xml_read怎么用?Python XML.xml_read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML
的用法示例。
在下文中一共展示了XML.xml_read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read_2
# 需要导入模块: import XML [as 别名]
# 或者: from XML import xml_read [as 别名]
def test_read_2(self) :
r = io.StringIO("<THU><Team><ACRush></ACRush><Jelly></Jelly><Cooly></Cooly></Team><JiaJia><Team><Ahyangyi></Ahyangyi><Dragon></Dragon><Cooly><Amber></Amber></Cooly></Team></JiaJia></THU><Team><Cooly></Cooly></Team>")
b, c = XML.xml_read(r)
self.assertTrue(tostring(b, encoding = 'unicode') == tostring(fromstring("<THU><Team><ACRush></ACRush><Jelly></Jelly><Cooly></Cooly></Team><JiaJia><Team><Ahyangyi></Ahyangyi><Dragon></Dragon><Cooly><Amber></Amber></Cooly></Team></JiaJia></THU>"),encoding='unicode'))
self.assertTrue(tostring(c, encoding = 'unicode') == tostring(fromstring("<Team><Cooly></Cooly></Team>"),encoding='unicode'))
示例2: test_read_3
# 需要导入模块: import XML [as 别名]
# 或者: from XML import xml_read [as 别名]
def test_read_3(self) :
r = io.StringIO("<red><green><blue></blue><yellow></yellow></green></red><red><green></green></red>")
b, c = XML.xml_read(r)
self.assertTrue(tostring(b, encoding = 'unicode') == tostring(fromstring("<red><green><blue></blue><yellow></yellow></green></red>"),encoding = 'unicode'))
self.assertTrue(tostring(c, encoding = 'unicode') == tostring(fromstring("<red><green></green></red>"),encoding = 'unicode'))
示例3: test_read_1
# 需要导入模块: import XML [as 别名]
# 或者: from XML import xml_read [as 别名]
def test_read_1 (self) :
r = io.StringIO("<cat><dog><bird><rat></rat></bird><chicken><goose></goose></chicken><egg></egg></dog><toy><car><race></race></car><computer><keyboard></keyboard></computer><monitor><mouse><pad></pad></mouse></monitor></toy></cat><cat><dog><bird></bird></dog></cat>")
b, c = XML.xml_read(r)
self.assertTrue(tostring(b,encoding='unicode') == tostring(fromstring("<cat><dog><bird><rat></rat></bird><chicken><goose></goose></chicken><egg></egg></dog><toy><car><race></race></car><computer><keyboard></keyboard></computer><monitor><mouse><pad></pad></mouse></monitor></toy></cat>"),encoding='unicode'))
self.assertTrue(tostring(c,encoding='unicode') == tostring(fromstring("<cat><dog><bird></bird></dog></cat>"),encoding='unicode'))