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


Python xpath.XPathQuery类代码示例

本文整理汇总了Python中twisted.words.xish.xpath.XPathQuery的典型用法代码示例。如果您正苦于以下问题:Python XPathQuery类的具体用法?Python XPathQuery怎么用?Python XPathQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了XPathQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_orOperator

 def test_orOperator(self):
     """
     Test boolean or operator in condition.
     """
     xp = XPathQuery("//bar[@attrib5='value4' or @attrib5='value5']")
     self.assertEqual(xp.matches(self.e), True)
     self.assertEqual(xp.queryForNodes(self.e), [self.bar5, self.bar6])
开发者ID:0004c,项目名称:VTK,代码行数:7,代码来源:test_xpath.py

示例2: test_attributeWithValueAny

 def test_attributeWithValueAny(self):
     """
     Test find nodes with attribute having value.
     """
     xp = XPathQuery("/foo/*[@attrib2='value2']")
     self.assertEqual(xp.matches(self.e), True)
     self.assertEqual(xp.queryForNodes(self.e), [self.bar2])
开发者ID:0004c,项目名称:VTK,代码行数:7,代码来源:test_xpath.py

示例3: test_locationFooBarFoo

 def test_locationFooBarFoo(self):
     """
     Test finding foos at the second level.
     """
     xp = XPathQuery("/foo/bar/foo")
     self.assertEquals(xp.matches(self.e), 1)
     self.assertEquals(xp.queryForNodes(self.e), [self.subfoo, self.subfoo3, self.subfoo4])
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:7,代码来源:test_xpath.py

示例4: test_queryForStringListAnyLocation

 def test_queryForStringListAnyLocation(self):
     """
     queryforStringList on relative paths returns all their CDATA.
     """
     xp = XPathQuery("//foo")
     self.assertEqual(xp.queryForStringList(self.e),
                       ["somecontent", "somemorecontent"])
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:7,代码来源:test_xpath.py

示例5: test_queryForString

 def test_queryForString(self):
     """
     Test for queryForString and queryForStringList.
     """
     xp = XPathQuery("/foo")
     self.assertEquals(xp.queryForString(self.e), "somecontent")
     self.assertEquals(xp.queryForStringList(self.e), ["somecontent", "somemorecontent"])
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:7,代码来源:test_xpath.py

示例6: test_position

 def test_position(self):
     """
     Test finding element at position.
     """
     xp = XPathQuery("/foo/bar[2]")
     self.assertEqual(xp.matches(self.e), 1)
     self.assertEqual(xp.queryForNodes(self.e), [self.bar1])
开发者ID:0004c,项目名称:VTK,代码行数:7,代码来源:test_xpath.py

示例7: test_locationAllChilds

 def test_locationAllChilds(self):
     """
     Test finding childs of foo.
     """
     xp = XPathQuery("/foo/*")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.bar1, self.bar2, self.bar4, self.bar5, self.bar6, self.bar7])
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:7,代码来源:test_xpath.py

示例8: test_textConditionUnicode

 def test_textConditionUnicode(self):
     """
     A node can be matched by text with non-ascii code points.
     """
     xp = XPathQuery(u"//*[text()='\N{SNOWMAN}']")
     self.assertEqual(xp.matches(self.e), True)
     self.assertEqual(xp.queryForNodes(self.e), [self.quux])
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:7,代码来源:test_xpath.py

示例9: test_andOperator

 def test_andOperator(self):
     """
     Test boolean and operator in condition.
     """
     xp = XPathQuery("//bar[@attrib4='value4' and @attrib5='value5']")
     self.assertEqual(xp.matches(self.e), True)
     self.assertEqual(xp.queryForNodes(self.e), [self.bar5])
开发者ID:0004c,项目名称:VTK,代码行数:7,代码来源:test_xpath.py

示例10: test_locationWithValueUnicode

 def test_locationWithValueUnicode(self):
     """
     Nodes' attributes can be matched with non-ASCII values.
     """
     xp = XPathQuery(u"/foo/*[@attrib6='á']")
     self.assertEqual(xp.matches(self.e), True)
     self.assertEqual(xp.queryForNodes(self.e), [self.bar7])
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:7,代码来源:test_xpath.py

示例11: test_anyLocationAndText

 def test_anyLocationAndText(self):
     """
     Test finding any nodes named gar and getting their text contents.
     """
     xp = XPathQuery("//gar")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.gar1, self.gar2, self.gar3, self.gar4])
     self.assertEquals(xp.queryForStringList(self.e), ["DEF", "ABC", "JKL", "MNO"])
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:8,代码来源:test_xpath.py

示例12: test_booleanOperatorsParens

 def test_booleanOperatorsParens(self):
     """
     Test multiple boolean operators in condition with parens.
     """
     xp = XPathQuery("""//bar[@attrib4='value4' and
                              (@attrib5='value4' or @attrib5='value6')]""")
     self.assertEqual(xp.matches(self.e), True)
     self.assertEqual(xp.queryForNodes(self.e), [self.bar6, self.bar7])
开发者ID:0004c,项目名称:VTK,代码行数:8,代码来源:test_xpath.py

示例13: test_queryForNodes

 def test_queryForNodes(self):
     """
     Test finding nodes.
     """
     xp = XPathQuery("/foo/bar")
     self.assertEqual(xp.queryForNodes(self.e), [self.bar1, self.bar2,
                                                  self.bar4, self.bar5,
                                                  self.bar6, self.bar7])
开发者ID:0004c,项目名称:VTK,代码行数:8,代码来源:test_xpath.py

示例14: test_anyLocation

 def test_anyLocation(self):
     """
     Test finding any nodes named bar.
     """
     xp = XPathQuery("//bar")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(
         xp.queryForNodes(self.e), [self.bar1, self.bar2, self.bar3, self.bar4, self.bar5, self.bar6, self.bar7]
     )
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:9,代码来源:test_xpath.py

示例15: test_textNotOperator

 def test_textNotOperator(self):
     """
     Test for not operator.
     """
     xp = XPathQuery("/foo[not(@nosuchattrib)]")
     self.assertEqual(xp.matches(self.e), True)
开发者ID:0004c,项目名称:VTK,代码行数:6,代码来源:test_xpath.py


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