当前位置: 首页>>代码示例>>Python>>正文


Python XML.countChildren方法代码示例

本文整理汇总了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)
开发者ID:SnehaR,项目名称:xml-tests,代码行数:9,代码来源:jv23358-TestXML.py

示例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
开发者ID:SnehaR,项目名称:xml-tests,代码行数:11,代码来源:jv23358-TestXML.py

示例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)
开发者ID:SnehaR,项目名称:xml-tests,代码行数:11,代码来源:jv23358-TestXML.py

示例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)
开发者ID:SnehaR,项目名称:xml-tests,代码行数:11,代码来源:jv23358-TestXML.py

示例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)
开发者ID:SnehaR,项目名称:xml-tests,代码行数:11,代码来源:jv23358-TestXML.py


注:本文中的XML.countChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。