Reputation: 21
I'm trying to parsing xml body from http response.
Here is what I want and what I'm doing.
<?xml version="1.0" encoding="UTF-8"?><deployment xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<deployment_details>
<host_uuid>1963aa56409abe71d8c449d6e2adf3eb816e8ccf75838bfa664ef803</host_uuid>
<host_name>my_hostname</host_name>
<vm_uuid>02c644ed-1a92-4efb-b80b-f1abbf5ea3b6</vm_uuid>
<generated_vm_name>esc-vnf-info-csr_csr-te_0_bf4121de-cd55-4b14-ad7a-6d4a3f572e02</generated_vm_name>
<interfaces>
<interface>
<binding_profile/>
<network_uuid>b76e4cd7-0d88-4889-b6fe-2430641c26cc</network_uuid>
<gateway>172.18.21.254</gateway>
<ip_address>172.18.21.132</ip_address>
<mac_address>fa:16:3e:17:86:67</mac_address>
<netmask>255.255.255.0</netmask>
<nic_id>0</nic_id>
<port_forwarding/>
<port_uuid>6c38a416-48b6-45d2-b192-2fe9971c1ed2</port_uuid>
<port_security_enabled>false</port_security_enabled>
<security_groups/>
<subnet_uuid>41330856-a0c9-4a04-be5b-b513c761da0e</subnet_uuid>
<type>virtual</type>
<vim_interface_name>esc-vnf-info-csr_csr-te_0_bf4121de-cd55-4b14-ad7a-6d4a3f572e02</vim_interface_name>
</interface>
</interfaces>
</deployment_details>
<deployment_name>info-csr-test</deployment_name>
</deployment>
${XML(response).xPath("/deployment/deployment_details/host_name").element()}
Cannot instantiate process definition esc_api_test:12:782eb51a-d4ec-11ec-ab99-5af27468b181: Error while evaluating expression: ${XML(response).xPath("/deployment/deployment_details/host_name").element()}. Cause: org.camunda.spin.xml.SpinXPathException: SPIN/DOM-XML-01035 Unable to find XPath expression '/deployment/deployment_details/host_name' [ start-instance-error ]
Does someone help my issue?
Upvotes: 1
Views: 375
Reputation: 21
I found other way to get the value as below code. xPath is not working but childElement is working well. ${XML(response).childElement("deployment_details").childElement("host_name").textContent()}
Upvotes: 1