Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Ansible:如何从URI(REST)XML输出解析XML值_Python_Regex_Xml_Ansible_Xml Parsing - Fatal编程技术网

Python Ansible:如何从URI(REST)XML输出解析XML值

Python Ansible:如何从URI(REST)XML输出解析XML值,python,regex,xml,ansible,xml-parsing,Python,Regex,Xml,Ansible,Xml Parsing,我有下面的Ansible playbook来访问我的服务器,并使用RESTAPI机制获取数据,我能够获得输出XML格式,但很难只解析该输出中的特定值 Ansible剧本-调试 - debug: var: steering - debug: msg="{{ steering | regex_findall('<name>(.*?)</name>') }}" - debug: msg="{{ steering | regex_findall('<value&

我有下面的Ansible playbook来访问我的服务器,并使用RESTAPI机制获取数据,我能够获得输出XML格式,但很难只解析该输出中的特定值

Ansible剧本-调试

- debug:
    var: steering

- debug: msg="{{ steering | regex_findall('<name>(.*?)</name>') }}"

- debug: msg="{{ steering | regex_findall('<value>(.*?)</value>') }}"
我如何才能同时获取
名称和值
,而不是单独的调试响应(通过修改regex_findall)。。或者,如果有可能合并上一次调试响应以获得
名称和值
,请提供帮助

预期输出

"ip-address - 10.10.10.12",
"start-port - 7000",
"end-port - 15000",
"realm-id - Core"
请帮忙


提前谢谢。

不要试图用螺丝刀拧紧螺栓:使用正确的工具。在这种情况下,您拥有Hi Zeitounator,感谢您的回复。。我看到了
xml模块
页面,但没有找到关于从xml响应中获取值的有用信息。真的吗?我确信您忽略了模块的
xmlstring
参数。不要试图用螺丝刀拧紧螺栓:使用正确的工具。在这种情况下,您拥有Hi Zeitounator,感谢您的回复。。我看到了
xml模块
页面,但没有找到关于从xml响应中获取值的有用信息。真的吗?我确信您忽略了模块的
xmlstring
参数。
"ip-address - 10.10.10.12",
"start-port - 7000",
"end-port - 15000",
"realm-id - Core"