有一個調用應用程序的Web服務的代碼。如何解析URI中的XML響應
- uri:
url: http://10.164.52.61:8080/ems/v74/ws/customer.ws?customerRefId=f4XXXb15d69c3
method: GET
content_as_json: true
password: admin
user: admin
validate_certs: no
return_content: yes
HEADER_Cookie: "{{login.set_cookie}}"
register: customerId
- debug:
var: customerId.content
樣本響應是
"customerId.content": "<listResponse type=\"customer\" count=\"1\"><instance customerId=\"28\" name=\"abc\" customerRefId=\"xyz\" refId1=\"12\" type=\"org\" enabled=\"true\" phone=\"\" fax=\"\" billingZip=\"\" billingAddress=\"\" billingCity=\"\" billingCountry=\"\" billingState=\"\" vendor=\"1\" defaultEmail=\"test\" defaultContactName=\"test\"/></listResponse>"
我要訪問我的代碼下一個塊列表響應。就像我只需要「customerId」的值。如何使用非對稱性來實現這一點
我有這個同樣的問題,而不是讓我得到什麼是味精中提到的任何值。就像這種情況一樣,它是「msg」:「{{customerId.content | regex_findall(\」customerId = \\\「(\\ d +)\\\」「)」}}「。這是這個特定任務的結果。 –
這不工作.. –
我已經更新了完整的工作示例的答案,請檢查它。 –