• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python xpath.XPathQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_textCondition

 def test_textCondition(self):
     """
     Test matching a node with given text.
     """
     xp = XPathQuery("/foo[text() = 'somecontent']")
     self.assertEqual(xp.matches(self.e), True)
开发者ID:0004c,项目名称:VTK,代码行数:6,代码来源:test_xpath.py


示例17: test_attributeWithValue

 def test_attributeWithValue(self):
     """
     Test matching node with attribute having value.
     """
     xp = XPathQuery("/foo[@attrib1='value1']")
     self.assertEqual(xp.matches(self.e), 1)
开发者ID:0004c,项目名称:VTK,代码行数:6,代码来源:test_xpath.py


示例18: test_namespaceNotFound

 def test_namespaceNotFound(self):
     """
     Test not matching node with wrong namespace.
     """
     xp = XPathQuery("/foo[@xmlns='badns']/bar2")
     self.assertEqual(xp.matches(self.e), 0)
开发者ID:0004c,项目名称:VTK,代码行数:6,代码来源:test_xpath.py


示例19: test_namespaceFound

 def test_namespaceFound(self):
     """
     Test matching node with namespace.
     """
     xp = XPathQuery("/foo[@xmlns='testns']/bar")
     self.assertEqual(xp.matches(self.e), 1)
开发者ID:0004c,项目名称:VTK,代码行数:6,代码来源:test_xpath.py


示例20: test_locationNoBar3

 def test_locationNoBar3(self):
     """
     Test not finding bar3.
     """
     xp = XPathQuery("/foo/bar3")
     self.assertEqual(xp.matches(self.e), 0)
开发者ID:0004c,项目名称:VTK,代码行数:6,代码来源:test_xpath.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python twisted_logger.writeLog函数代码示例发布时间:2022-05-27
下一篇:
Python xpath.queryForNodes函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap