本文整理汇总了Python中XML.countChildren方法的典型用法代码示例。如果您正苦于以下问题:Python XML.countChildren方法的具体用法?Python XML.countChildren怎么用?Python XML.countChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML
的用法示例。
在下文中一共展示了XML.countChildren方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_countChildren_multipleChildren
# 需要导入模块: import XML [as 别名]
# 或者: from XML import countChildren [as 别名]
def test_countChildren_multipleChildren(self):
s = "<xml><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><Jelly></Jelly></Team></xml>"
a = fromstring(s)
pattern = XML.getPattern(a)
patternChildren = 0
patternChildren = XML.countChildren(pattern)
self.assertTrue(patternChildren == 2)
示例2: test_findMatches
# 需要导入模块: import XML [as 别名]
# 或者: from XML import countChildren [as 别名]
def test_findMatches(self):
s = "<xml><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></xml>"
a = fromstring(s)
pattern = XML.getPattern(a)
patternChildren = 0
patternChildren = XML.countChildren(pattern)
XML.locations = []
XML.locations = XML.findMatches(a, pattern, patternChildren)
self.assertTrue(XML.locations == []) #function only works in conjunction with the count function
示例3: test_count_breadth
# 需要导入模块: import XML [as 别名]
# 或者: from XML import countChildren [as 别名]
def test_count_breadth(self):
s = "<xml><THU><Team></Team><ACRush></ACRush><Jelly></Jelly><Cooly></Cooly><JiaJia></JiaJia><Ahyangyi></Ahyangyi><Dragon></Dragon></THU></xml>"
a = fromstring(s)
pattern = XML.getPattern(a)
patternChildren = 0
patternChildren = XML.countChildren(pattern)
XML.numElements = 0
XML.numElements = XML.count(a, pattern, patternChildren)
self.assertTrue(XML.numElements == 8)
示例4: test_count
# 需要导入模块: import XML [as 别名]
# 或者: from XML import countChildren [as 别名]
def test_count(self):
s = "<xml><THU>\n\t<Team>\n\t\t<ACRush></ACRush>\n\t\t<Jelly></Jelly>\n\t\t<Cooly></Cooly>\n\t</Team>\n\t<JiaJia>\n\t\t<Team>\n\t\t\t<Ahyangyi></Ahyangyi>\n\t\t\t<Dragon></Dragon>\n\t\t\t<Cooly><Amber></Amber></Cooly>\n\t\t</Team>\n\t</JiaJia>\n</THU>\n<Team><Cooly></Cooly></Team>\n</xml>"
a = fromstring(s)
pattern = XML.getPattern(a)
patternChildren = 0
patternChildren = XML.countChildren(pattern)
XML.numElements = 0
XML.numElements = XML.count(a, pattern, patternChildren)
self.assertTrue(XML.numElements == 13)
示例5: test_findMatches_guaranteed_match
# 需要导入模块: import XML [as 别名]
# 或者: from XML import countChildren [as 别名]
def test_findMatches_guaranteed_match(self):
s = "<xml><THU><Team></Team></THU><THU></THU></xml>"
a = fromstring(s)
pattern = XML.getPattern(a)
patternChildren = 0
patternChildren = XML.countChildren(pattern)
XML.matches = 0
XML.findMatches(a, pattern, patternChildren)
self.assertTrue(XML.matches == 0)