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


Python XML.findall方法代码示例

本文整理汇总了Python中lxml.etree.XML.findall方法的典型用法代码示例。如果您正苦于以下问题:Python XML.findall方法的具体用法?Python XML.findall怎么用?Python XML.findall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lxml.etree.XML的用法示例。


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

示例1: parse_gir

# 需要导入模块: from lxml.etree import XML [as 别名]
# 或者: from lxml.etree.XML import findall [as 别名]
def parse_gir(gir_path):
    """Extract everything from a gir file"""
    print("Parsing {}".format(gir_path))
    parser = XMLParser(encoding="utf-8", recover=True)
    content = open(gir_path).read()
    root = XML(content, parser)
    namespace = root.findall("{%s}namespace" % XMLNS)[0]
    namespace_content = extract_namespace(namespace)
    return namespace_content
开发者ID:strycore,项目名称:fakegir,代码行数:11,代码来源:fakegir.py

示例2: process_update

# 需要导入模块: from lxml.etree import XML [as 别名]
# 或者: from lxml.etree.XML import findall [as 别名]
 def process_update(self, xml):
     messages = []
     
     xml = XML(xml)
     msgs = xml.findall("log/msg")
     
     for msg in msgs:
         author = msg.findtext("author")
         text = msg.findtext("text")
         messages.append(ChatMessage(author, text))
     
     self.messages = messages
开发者ID:jordanorc,项目名称:hipweb,代码行数:14,代码来源:api.py

示例3: _add_children

# 需要导入模块: from lxml.etree import XML [as 别名]
# 或者: from lxml.etree.XML import findall [as 别名]
	def _add_children(self, bus, service):
		'''Add the child nodes found by introspection'''
		self._children= {};
		xml = self._object.Introspect()
		data = XML(xml)

		# add all child nodes
		for child in data.findall('node'):
			name = child.get('name')
			if name == "/":
				continue

			child_path = self.object.object_path
			# root is reported as /, don't make it //
			if child_path != "/":
				child_path += "/"
			child_path += name
			self._children[name] = Dbusitem(bus, service, child_path)
开发者ID:hatef207,项目名称:velib_python,代码行数:20,代码来源:dbusitem.py

示例4: _mock_manager_3foobar_warnings

# 需要导入模块: from lxml.etree import XML [as 别名]
# 或者: from lxml.etree.XML import findall [as 别名]
 def _mock_manager_3foobar_warnings(self, *args, **kwargs):
     cmd = """
     <load-configuration action="set" format="text">
         <configuration-set>
             delete interfaces ge-0/0/0
             delete protocols ospf
             delete policy-options prefix-list foo
         </configuration-set>
     </load-configuration>
     """
     rsp_string = """
     <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/16.1R4/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:1f3dfa00-3434-414a-8aa8-0073590c5812">
         <load-configuration-results>
             <rpc-error>
                 <error-severity>warning</error-severity>
                 <error-message>
                     foo boom
                 </error-message>
             </rpc-error>
             <rpc-error>
                 <error-severity>warning</error-severity>
                 <error-message>
                     boom bar
                 </error-message>
             </rpc-error>
             <rpc-error>
                 <error-severity>warning</error-severity>
                 <error-message>
                     foo bar
                 </error-message>
             </rpc-error>
             <ok/>
         </load-configuration-results>
     </rpc-reply>
     """
     rsp = XML(rsp_string)
     errors = []
     for err in rsp.findall('.//'+qualify('rpc-error')):
         errors.append(RPCError(err))
     raise RPCError(rsp, errs=errors)
开发者ID:GIC-de,项目名称:py-junos-eznc,代码行数:42,代码来源:test_decorators.py


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