xml - 遍历来自 xml 的列表会导致 Ansible
问题描述
我有这样的xml
回应:
"model": {
"results": [ {"item": "A", "xml":"...."}, {"item": "B", "xml":"...."} ]
}
我正在尝试遍历结果列表并获取元素“xml”。现在我正在做这样的事情:
- name: Retrieve xml tags
xml:
xmlstring: "{{ item.string }}"
xpath: "{{ item.path }}"
content: text
loop:
- { path: "/rpc-reply/lldp-remote-system-name", string: "{{ model.results[].xml }}" }
但这不起作用。我也试过这个:
model.results[*].xml
但这是错误的。
我试图在里面添加第二个循环,但我什么也没得到。有什么建议么 ?
解决方案
您可以循环浏览列表作为响应,如下所示:
- name: xml tags
xml:
xmlstring: "{{ item.xml }}"
xpath: "/rpc-reply/lldp-remote-system-name"
content: text
loop: "{{ model.results }}"
推荐阅读
- neo4j - Neo4j:查找与列表中所有节点有连接的节点
- spring-batch - 项目阅读器中的 Spring Batch 作业参数
- python - scikit KernelDensity 返回平面密度
- sql - 使用 left() 函数的左外连接
- c++ - 使用 TinyCbor C 库对 uint8_t 进行编码和解码
- c++ - 用特征计算两条线的交点
- reactjs - 完全没有路由的反应 SPA
- c# - 在 Visual Studio 7.5 mac 中找不到指定的框架“Microsoft.AspNetCore.App”,版本“2.1.0”
- facebook - Trim 和 Plum 等聊天机器人如何将您的 Facebook Messenger 帐户链接到他们自己的第三方帐户以及银行帐户?
- cloud-foundry - Cloud Foundry 默认基础架构