Hello i have an call where i get an XML response back. I am trying to fetch a specific value from that call and assign it. I do get response back so the call is working, but not sure how to narrow down to the correct level to get the value
There are numerous ways that you could extract the specific XML Node Content some more straight forward than another depending on how complex the XML structure is. You could use Regular Expressions on more simple XML, access the DOM among others, but typically my go to is XPath (XML Path Language).
(Sidebar! When asking the community for assistance it is often a curtesy to provide the raw source when possible of the data you are working in, that way it becomes more accessible to those the desire to help out. I’ve taken the liberty of of using OCR and will provide the XML in text form below)
What we are asking for is search (//) for node with name of SetReadPostedSalesInvoices that also has a child-node of name Key
Assuming it will always be a single node/element we are expecting, we then can convert the resulting XPath object into a String using the fn:string() function, otherwise you could leave off the string function and would get an object with an array of elements found.
^^ In the above I duplicated the <SetReadPostedSalesInvoices> element.
I have a few older posts that I provide some XPath examples and lots more information on the Internet!